﻿if (typeof $ === 'undefined') { throw new Error('This application\'s JavaScript requires jQuery'); }
var App = angular.module('angle', [
    'ngRoute',
  //  'ngAnimate',
   // 'ngStorage',
  //  'ngCookies',
   // 'pascalprecht.translate',
    //'ui.bootstrap',
    'ui.router',
    'oc.lazyLoad',
    'cfp.loadingBar',
   // 'ngSanitize',
  //  'ngResource',
  //  'tmh.dynamicLocale',
   // 'ui.utils',
    'angular.filter',
    'angular-loading-bar',
  'treasure-overlay-spinner',
'infinite-scroll'//分页加载
    //'RecursionHelper'

   // 'ngTouch'
]);
run.$inject = ['$rootScope'];
function run($rootScope) {
    $rootScope.spinner = {
        active: false,
        on: function () {
            this.active = true;
        },
        off: function () {
            this.active = false;
        }
    };
}
App.run(run);
App.run(["$rootScope", "$state", "$stateParams", '$window', '$templateCache',  '$http', '$filter', '$location', '$timeout',
    function ($rootScope, $state, $stateParams, $window, $templateCache,  $http, $filter, $location, $timeout) {
        // Set reference to access them from any scope
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
        $rootScope.$storage = $window.localStorage;
        //  $rootScope.metabcy = "width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0";

        // Uncomment this to disable template cache
        //$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
        //    if (typeof(toState) !== 'undefined'){
        //      $templateCache.remove(toState.templateUrl);
        //    }
        //});
        $rootScope.GoBack = function () {
            window.history.back();
        };
        $rootScope.KeepScroll = function (css) {
            var hp = parseInt($rootScope.scrollPos[$location.path()] ? $rootScope.scrollPos[$location.path()] : 0);
            var wh = $(window).height();
            $(css).css("min-height", hp + wh);
            window.scrollTo(0, hp);
            $rootScope.okSaveScroll = true;
        }
        $rootScope.ImgUploadUrl = "http://file.xsmore.com/api/image/upload";
        //$rootScope.$on('$viewContentLoaded', function () {
        //    $templateCache.removeAll();
        //});

        // Scope Globals
        // ----------------------------------- 
        $rootScope.app = {
            //     name: '不错哟',
            description: '社交购物',
            year: ((new Date()).getFullYear()),
            layout: {
                isFixed: true,
                isCollapsed: false,
                isBoxed: false,
                isRTL: false,
                horizontal: false,
                isFloat: false,
                asideHover: false,
                theme: null
            },
            useFullLayout: false,
            hiddenFooter: false,
            viewAnimation: 'ng-fadeInUp',
            name: '',
            isweixin: $window.navigator.userAgent.indexOf('MicroMessenger') > -1

        };
        //var mall = $cookieStore.get("zmkmmall3");
        //console.log(mall);
        //if (!mall || mall.host !== $location.host()) {
        $http.post("/shop/mall").success(function (response) {
            var mall = { name: response.Name, host: $location.host(), MallId: response.MallId };
            // $cookieStore.put("zmkmmall3", mall);
            $rootScope.app.name = mall.name;
            $rootScope.app.mallid = mall.MallId;
            $rootScope.app.MallType = response.MallType;
            $rootScope.app.ChildMode = response.ChildMode;
            $rootScope.app.Style = response.Style;
            $rootScope.PCUrl = response.PCUrl;
            $rootScope.app.IsOpen = response.IsOpen;
            //var $body = $('body');
            //document.title = mall.name;
            //// hack在微信等webview中无法修改document.title的情况
            //var $iframe = $('<iframe src="/favicon.ico" style="display:none"></iframe>');
            //$iframe.on('load', function () {
            //    setTimeout(function () {
            //        $iframe.off('load').remove();
            //    }, 0);
            //}).appendTo($body);


        });
        //} else {
        //    $rootScope.app.name = mall.name;
        //    $rootScope.app.mallid = mall.MallId;
        //}


        //    $rootScope.indexColor = function () {
        //        return $rootScope.app.Style.Color;
        //        //var key = "indexcolor" + $rootScope.app.mallid;
        //        //var indexcolor = $cookieStore.get(key);
        //        //if (!indexcolor) {
        //        //    return "green";
        //        //} else {
        //        //    return indexcolor;
        //        //}
        //    };
        //$rootScope.SetIndexColor = function (mallid, color) {
        //    if (color) {
        //        var key = "indexcolor" + mallid;
        //        $cookieStore.put(key, color);}
        //};

        $rootScope.WxConfig = function (url) {
            $http.post('/weixin/wxconfig', { Url: url, MallId: $rootScope.app.mallid }).success(function (response) {
                var d = {
                    debug: false,
                    appId: response.appid,
                    timestamp: response.timestamp,
                    nonceStr: response.nonceStr,
                    signature: response.signature,
                    jsApiList: response.jsApiList
                };
                wx.config(
                   {
                       debug: false,
                       appId: response.appid,
                       timestamp: response.timestamp,
                       nonceStr: response.nonceStr,
                       signature: response.signature,
                       jsApiList: response.jsApiList
                   }
                );
            });
        }

        $rootScope.WxShare = function (title, desc, url, imgurl, suc, can) {
            wx.ready(function () {
                //wx.error(function (res) {
                //    alert(JSON.stringify(res));
                //});
                var shareData = {
                    title: title, // 分享标题
                    desc: desc, // 分享语
                    link: url, // 分享链接
                    imgUrl: imgurl,
                    success: suc,
                    cancel: can
                };
                wx.showOptionMenu();
                wx.onMenuShareTimeline(shareData);
                wx.onMenuShareAppMessage(shareData);
                wx.onMenuShareWeibo(shareData);
                wx.onMenuShareQQ(shareData);
                wx.onMenuShareQZone(shareData);
            });
        }
        $timeout(function () { $rootScope.WxConfig(encodeURIComponent(location.href.split('#')[0])); }, 1000);

        //内外网网址分开
        $rootScope.WxShare2 = function (title, desc, url1, url2, imgurl, suc, can) {
            wx.ready(function () {
                //wx.error(function (res) {
                //    alert(JSON.stringify(res));
                //});
                var shareData1 = {
                    title: title, // 分享标题
                    desc: desc, // 分享语
                    link: url1, // 分享链接
                    imgUrl: imgurl,
                    success: suc,
                    cancel: can
                };
                var shareData2 = {
                    title: title, // 分享标题
                    desc: desc, // 分享语
                    link: url2, // 分享链接
                    imgUrl: imgurl,
                    success: suc,
                    cancel: can
                };
                wx.showOptionMenu();
                wx.onMenuShareTimeline(shareData1);
                wx.onMenuShareAppMessage(shareData1);
                wx.onMenuShareWeibo(shareData2);
                wx.onMenuShareQQ(shareData2);
                wx.onMenuShareQZone(shareData2);
            });
        }

        $rootScope.sum = function (items, prop) {
            if (items == null) {
                return 0;
            }
            return items.reduce(function (a, b) {
                return b[prop] == null ? a : a + parseFloat(b[prop]);
            }, 0);
        };

        $rootScope.ActivityTypeName = function (type) {
            switch (type) {
                case 2:
                    return "满减";
                case 3:
                    return "满换购";
                case 4:
                    return "满赠";
                case 6:
                    return "满赠优惠券";
                case 7:
                    return "买赠";
                default:
                    return "";
            }
        }



        $rootScope.ShortP = function (name) {
            if (name === "内蒙古自治区" || name === "黑龙江省") {
                name = name.substring(0, 3);
            }
            else
                name = name.substring(0, 2);
            return name;
        }
        $rootScope.OrderStateName = function (state) {
            switch (state) {
                case 1:
                    return "待付款";
                case 2:
                case 3:
                    return "待发货";
                case 4:
                    return "已发货";
                case 5:
                    return "已完成";
                case 6:
                    return "申请取消";
                case 8:
                    return "已取消";
                case 9:
                    return "待成团";
                default:
                    return "";
            }
        }
        $rootScope.LogisticsTypeName = function (type) {
            switch (type) {
                case "0":
                    return "商家配送";
                case "1":
                    return "保税仓发货";
                case "2":
                    return "海外直邮";

                default:
                    return "";
            }
        }
        $rootScope.SupportStateName = function (state) {
            switch (state) {
                case 1:
                    return "商品已寄回,待审核";
                case 2:
                    return "退换货完成";
                case 3:
                    return "售后否决";
                case 4:
                    return "已撤销";
                case 5:
                    return "申请中,待审核  ";
                case 6:
                    return "等待寄回";
                case 7:
                    return "申请否决";
                case 8:
                    return "已关闭";
                default:
                    return "";
            }
        }
        $rootScope.CommissionStateName = function (cstate) {
            var state = parseInt(cstate, 10);
            switch (state) {

                default:
                    return "";
            }
        }
        $rootScope.DealTypeName = function (dealType) {
            switch (state) {
                case 1:
                    return "正常购买";
                case 2:
                    return "换购";
                case 3:
                    return "买赠";
                case 4:
                    return "秒杀";
                case 5:
                    return "奖品";

                default:
                    return "";
            }
        }

        $rootScope.CommissionTypeName = function (commissionType) {
            switch (commissionType) {
                case 1:
                    return "自营零售奖励";
                case 2:
                    return "直接零售奖励";
                case 3:
                    return "间接零售奖励";
                case 4:
                    return "直接招募奖励";
                case 5:
                    return "间接招募奖励";
                case 6:
                    return "下级升级奖励";
                case 7:
                    return "普通推荐奖励";
                    //case 8:
                    //    return "下级招募平级奖励";
                case 9:
                    return "下级升级招募奖励";
                case 10:
                    return "推荐零售奖励";
                case 11:
                    return "高级推荐奖励";
                case 12:
                    return "高级直招奖励";
                case 13:
                    return "平级推荐奖励";
                case 14:
                    return "推荐一级奖励";
                case 15:
                    return "推荐二级奖励";
                case 16:
                    return "下级推荐招募奖励";
                case 17:
                    return "普通推荐晋升奖励";
                case 18:
                    return "高级推荐晋升奖励";
                case 19:
                    return "其他下级晋升奖励";
                case 20:
                    return "直招下级晋升奖励";
                case 21:
                    return "金团队零售奖励";
                case 22:
                    return "合团队零售奖励";
                case 23:
                    return "团队发展奖励";
                case 24:
                    return "团队销售业绩奖励";
                case 25:
                    return "跨级新晋奖励";
                case 26:
                    return "升级推荐招募奖励";
                case 27:
                    return "合老师团队零售奖励";
                default:
                    return "";
            }
        }
        $rootScope.CommissionStateName = function (cstate) {
            var state = parseInt(cstate, 10);
            switch (state) {

                case 1:
                    return "待结算";
                case 2:
                    return "可提现";
                case 3:
                    return "提现中";
                case 4:
                    return "已提现";
                case 5:
                    return "已退款";
                case 6:
                    return "无效";
                case 7:
                    return "财务否决";
                default:
                    return "";
            }
        }
        $rootScope.selectKeys = function (items) {
            var keys = [];
            angular.forEach(items, function (item, key) {
                keys.push(key);
            });
            return keys;
        }
        $rootScope.GroupBuyStateName = function (cstate) {
            var state = parseInt(cstate, 10);
            switch (state) {

                case 1:
                    return "组团中";
                case 2:
                    return "已成团";
                case 3:
                    return "组团失败";
                default:
                    return "未成团";
            }
        }

        $rootScope.NumDx = function numtochinese(num) {
            var currencyDigits = num.toString();

            var MAXIMUM_NUMBER = 99999999999.99;  //最大值
            // 定义转移字符
            var CN_ZERO = "零";
            var CN_ONE = "壹";
            var CN_TWO = "贰";
            var CN_THREE = "叁";
            var CN_FOUR = "肆";
            var CN_FIVE = "伍";
            var CN_SIX = "陆";
            var CN_SEVEN = "柒";
            var CN_EIGHT = "捌";
            var CN_NINE = "玖";
            var CN_TEN = "拾";
            var CN_HUNDRED = "佰";
            var CN_THOUSAND = "仟";
            var CN_TEN_THOUSAND = "万";
            var CN_HUNDRED_MILLION = "亿";
            var CN_DOLLAR = "元";
            var CN_TEN_CENT = "角";
            var CN_CENT = "分";
            var CN_INTEGER = "整";

            // 初始化验证:
            var integral, decimal, outputCharacters, parts;
            var digits, radices, bigRadices, decimals;
            var zeroCount;
            var i, p, d;
            var quotient, modulus;

            currencyDigits = currencyDigits.replace(/,/g, "");
            currencyDigits = currencyDigits.replace(/^0+/, "");


            parts = currencyDigits.split(".");
            if (parts.length > 1) {
                integral = parts[0];
                decimal = parts[1];
                decimal = decimal.substr(0, 2);
            }
            else {
                integral = parts[0];
                decimal = "";
            }
            // 实例化字符大写人民币汉字对应的数字
            digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE);
            radices = new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND);
            bigRadices = new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION);
            decimals = new Array(CN_TEN_CENT, CN_CENT);

            outputCharacters = "";
            //大于零处理逻辑
            if (Number(integral) > 0) {
                zeroCount = 0;
                for (i = 0; i < integral.length; i++) {
                    p = integral.length - i - 1;
                    d = integral.substr(i, 1);
                    quotient = p / 4;
                    modulus = p % 4;
                    if (d == "0") {
                        zeroCount++;
                    }
                    else {
                        if (zeroCount > 0) {
                            outputCharacters += digits[0];
                        }
                        zeroCount = 0;
                        outputCharacters += digits[Number(d)] + radices[modulus];
                    }
                    if (modulus == 0 && zeroCount < 4) {
                        outputCharacters += bigRadices[quotient];
                    }
                }
                outputCharacters += CN_DOLLAR;
            }
            // 包含小数部分处理逻辑
            if (decimal != "") {
                for (i = 0; i < decimal.length; i++) {
                    d = decimal.substr(i, 1);
                    if (d != "0") {
                        outputCharacters += digits[Number(d)] + decimals[i];
                    }
                }
            }
            //确认并返回最终的输出字符串
            if (outputCharacters == "") {
                outputCharacters = CN_ZERO + CN_DOLLAR;
            }
            if (decimal == "") {
                outputCharacters += CN_INTEGER;
            }
            return outputCharacters;
        };
        $rootScope.shortDate = function (d) {
            var dd = new Date(d);
            return $filter('date')(dd, 'yyyy-MM-dd');
        };
        $rootScope.date = function () {
            var dd = new Date();
            return $filter('date')(dd, 'yyyy-MM-dd');
        };

        $rootScope.ImgHost = "http://img.xsmore.com/zmkm";
        $rootScope.OpenCoupon = function (coupon, shopno, r, mcid) {
            // console.log(coupon);
            if (r) {
                return;
            }
            switch (coupon.CouponType) {

                case 1:
                    $state.go('shop.index2');
                    break;
                case 2:
                    $state.go('shop.productlist', { shopno: shopno, skus: JSON.stringify(coupon.ApplyIds), cpid: coupon.Id, mcid: mcid });
                    break;
                case 3:
                    var cd = { shopno: shopno, cateId: coupon.ApplyIds[0], cpid: coupon.Id, mcid: mcid };
                    if (coupon.ApplyIds.length > 1) {
                        cd.cateIds = JSON.stringify(coupon.ApplyIds);
                    }
                    $state.go('shop.productlist', cd);
                    break;
                case 4:
                    var bd = { shopno: shopno, brand: coupon.ApplyIds[0], cpid: coupon.Id, mcid: mcid };
                    if (coupon.ApplyIds.length > 1) {
                        bd.brands = JSON.stringify(coupon.ApplyIds);
                    }
                    $state.go('shop.productlist', bd);
                    break;

                default:
            }

        };

        $rootScope.CouponType = function (coupon) {
            switch (coupon.CouponType) {
                case 1:
                    return "通用券";
                case 2:
                    return "商品券";
                case 3:

                case 4:
                    return "品类券";

                default:
                    return "";
            }
        };

        $rootScope.GetStyle = function (coupon) {
            if (!coupon.Color) {
                coupon.Color = 'blue';
            }
            if (!coupon.Style) {
                coupon.Style = 0;
            }
            switch (coupon.Style) {
                case 0:
                case 1:
                    return coupon.Color + " list" + coupon.Style + "-" + coupon.Color + " clearfix";
                case 2:
                    return "color " + coupon.Color + " clearfix";
                case 3:
                    return "list-det";


                default:
            }
        }

        $rootScope.Grab = function (coupon) {
            return $http.post('/homePageCouponActivity/grabnew', { Id: coupon.Id, ActivityId: $stateParams.id, MemberId: $stateParams.mid }).success(function (response) {
                coupon.Grab = true;

            }).error(function (response) {
                if (response.ErrorCode == 1100002) {
                    coupon.Grab = true;
                } else
                    alert(response.Message);
                if (response.ErrorCode === 1100003) {
                    location.reload();
                }
            });

        }

        $rootScope.ChangeTitle = function (title) {
            $rootScope.currTitle = title;
            if ($rootScope.app.isweixin) {
                document.title = title;
                var $body = $('body');
                var $iframe = $('<iframe src="/favicon.ico" style="display:none"></iframe>');
                $iframe.on('load', function () {
                    setTimeout(function () {
                        $iframe.off('load').remove();
                    }, 0);
                }).appendTo($body);
            }
        }

    }]);
angular.module('exceptionOverride', []).factory('$exceptionHandler', function () {
    return function (exception, cause) {
        exception.message += ' (caused by "' + cause + '")';
        throw exception;
    };
});
App.filter('to_trusted', ['$sce', function ($sce) {
    return function (text) {
        return $sce.trustAsHtml(text);
    };
}]);
App.config(
    function($httpProvider) {
        $httpProvider.interceptors.push(function($timeout, $q, $injector, $window) {
            var $http, $state, $location;
            $timeout(function() {

                $http = $injector.get('$http');
                $state = $injector.get('$state');
                $location = $injector.get('$location');
            });
            return {
                'requestError': function(rejection) {
                    // handle same as below
                },

                'responseError': function(rejection) {
                    if (rejection.status === 401) {
                        if ($state.current.name !== "login") {
                            var userAgent = $window.navigator.userAgent;


                            if (userAgent.indexOf("MicroMessenger") > -1) {
                                $window.location.replace("/auth/weixin?redirect=" +
                                    encodeURIComponent($location.absUrl()));
                            } else {
                                //   var r = encodeURIComponent("#" + $location.url());
                                //   window.location.replace("/#/login/?redirect=" + r);
                                $state.go("login", { redirect: "#" + $location.url() }, { location: 'replace' });
                            }
                        } else {
                            return $q.reject(rejection);
                        }

                        //   $state.go("/auth", { provider: 'weixin' });
                    } else if (rejection.status === 403) {
                        return $q.reject(rejection);
                    } else {

                        //     $state.transitionTo('404');
                    }
                    return $q.reject(rejection);
                },
                'response': function(response) {
                    if (response.data.ErrorCode === '' || response.data.ErrorCode === '500') {
                        //  alert(response.data.Message);
                        //  return $q.reject(response);
                        $state.go('message', { msg: response.data.Message }, { location: 'replace' });
                        //  $state.go('message', { msg: response.data.Message });
                    } else if (response.data.ErrorCode && response.data.ErrorCode !== '') {
                        return $q.reject(response);
                    }
                    return response;
                }
            };
        });
    });
//App.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {

//    //..省略代码
//    $locationProvider.html5Mode(true);
//}]);

App.config([
    '$ocLazyLoadProvider', 'APP_REQUIRES', function ($ocLazyLoadProvider, APP_REQUIRES) {
        'use strict';

        // Lazy Load modules configuration
        $ocLazyLoadProvider.config({
            debug: false,
            events: true,
            modules: APP_REQUIRES.modules
        });

    }
]).config([
    '$controllerProvider', '$compileProvider', '$filterProvider', '$provide',
    function ($controllerProvider, $compileProvider, $filterProvider, $provide) {
        'use strict';
        // registering components after bootstrap
        App.controller = $controllerProvider.register;
        App.directive = $compileProvider.directive;
        App.filter = $filterProvider.register;
        App.factory = $provide.factory;
        App.service = $provide.service;
        App.constant = $provide.constant;
        App.value = $provide.value;

    }
])
    .config([
    'cfpLoadingBarProvider', function (cfpLoadingBarProvider) {

        cfpLoadingBarProvider.includeBar = true;
        cfpLoadingBarProvider.includeSpinner = false;
        cfpLoadingBarProvider.latencyThreshold = 100;
        //  cfpLoadingBarProvider.spinnerTemplate = '<div class="cfgspinner" style="z-index:9999px;opacity: 1; position: absolute;top:50%;left:50%;"><img src=""></div>';
        cfpLoadingBarProvider.parentSelector = '.wrapper > section';

    }
    ])
;

App.provider('RouteHelpers', ['APP_REQUIRES', function (appRequires) {
    "use strict";

    // Set here the base of the relative path
    // for all app views
    this.basepath = function (uri) {
        return '/views/' + uri;
    };

    // Generates a resolve object by passing script names
    // previously configured in constant.APP_REQUIRES
    this.resolveFor = function () {
        var _args = arguments;
        return {
            deps: ['$ocLazyLoad', '$q', function ($ocLL, $q) {
                // Creates a promise chain for each argument
                var promise = $q.when(1); // empty promise
                for (var i = 0, len = _args.length; i < len; i++) {
                    promise = andThen(_args[i]);
                }
                return promise;

                // creates promise to chain dynamically
                function andThen(_arg) {
                    // also support a function that returns a promise
                    if (typeof _arg == 'function')
                        return promise.then(_arg);
                    else
                        return promise.then(function () {
                            // if is a module, pass the name. If not, pass the array
                            var whatToLoad = getRequired(_arg);
                            // simple error check
                            if (!whatToLoad) return $.error('Route resolve: Bad resource name [' + _arg + ']');
                            // finally, return a promise
                            return $ocLL.load(whatToLoad);
                        });
                }
                // check and returns required data
                // analyze module items with the form [name: '', files: []]
                // and also simple array of script files (for not angular js)
                function getRequired(name) {
                    if (appRequires.modules)
                        for (var m in appRequires.modules)
                            if (appRequires.modules[m].name && appRequires.modules[m].name === name)
                                return appRequires.modules[m];
                    return appRequires.scripts && appRequires.scripts[name];
                }

            }]
        };
    }; // resolveFor

    // not necessary, only used in config block for routes
    this.$get = function () {
        return {
            basepath: this.basepath
        }
    };

}]);
App.controller("ShopIndexCtrlv2", [
    '$scope', '$http', '$stateParams', '$timeout', '$state', '$rootScope', '$compile', '$location', 'shophot', '$filter', '$window', 'Reddit', 'mallStyleService', function ($scope, $http, $stateParams, $timeout, $state, $rootScope, $compile, $location, shophot, $filter, $window, Reddit, mallStyleService) {
        var shopno = $stateParams.shopno;
        $scope.SingleProductIndex = 0;
        $scope.UiSrefIds = [];
        $scope.UiSrefSkus = [];
        $scope.GoUrl = function (url) {
            location.href = url;
        }
        var brandwheel = false;

        var pageindex = $state.current.name === "shop.index2" || $state.current.name === "shop.index";
        $scope.PageId = pageindex ? 0 : $stateParams.Id;

        var posturl = pageindex ? "/shop/index" : "/otherPageManagement/lookover";
        var postdata = pageindex ? { ShopNo: shopno } : { Id: $stateParams.Id, ShopNo: shopno };
        $http.post(posturl, postdata).success(function (response) {
            $scope.Member = response.Member;
            shopno = $scope.Member.ShopNo;
            $scope.Favorited = response.Favorited;
            $scope.Mall = response.Mall;
            $scope.IsMember = response.IsMember;
            if (pageindex) {
                shophot.AddHot(response.Member.Id, "", "店铺首页");
            } else {
                $scope.OtherPageTitle = response.MsdList.PageName;
                $rootScope.ChangeTitle(response.MsdList.PageName);
            }
            $scope.TitleBg = response.MsdList.StyleContent.TitleBg;
            $scope.games = response.Games;
            var html = "";
            var dc = pageindex ? $filter('orderBy')(response.MsdList.DecorateContent, "MouduleOrder") : $filter('orderBy')(response.MsdList.PageContent, "MouduleOrder");
            $scope.ProductReddits = [];
            $scope.SingleProductReddits = [];

            html = mallStyleService.GetHtml(dc, $scope);

            angular.element(document.getElementById('html')).append($compile(html)($scope));
            $(function () {
                // 四种轮播图
                $('.slick1').slick({
                    dots: true,
                    autoplay: true
                });

                $('.slick2').slick({
                    dots: true,
                    autoplay: true,
                });

                $('.slick3').slick({
                    dots: false,
                    autoplay: true,
                    arrows: true,
                });
                $('.slick4').each(function (i, e) {
                    var amount = $("img", e).length;
                    //console.log(amount);
                    $(' .big', e).html(amount);

                    $(e).slick({
                        dots: false,
                        autoplay: true,
                        onAfterChange: function (ele, index) {
                            $(" .small", e).html(index + 1);
                        }
                    });
                })



                $(".video-wraper .play").on("click", function () {
                    var video = $("video", this.parentNode)[0];
                    video.play();

                    $(".cover,.play", this.parentNode).hide();
                });
            });
            $timeout(function () {
                var shopname = $scope.Mall.MallKey == $scope.Member.ShopNo
                    ? $scope.Mall.Name
                    : $scope.Mall.Name + '-' + $scope.Member.ShopName;
                var shareStr = $scope.Member.ShopDesc;
                if (!shareStr) {
                    shareStr = $scope.ShopNotify;
                }
                // $rootScope.WxShare(shopname, shareStr, location.href, $scope.Member.HeadUrl);
                if (pageindex) {
                    $rootScope.WxShare(shopname, shareStr, "http://" + $location.host() + "/#/shop/?shopno=" + shopno, $scope.Member.HeadUrl);
                } else {
                    $rootScope.WxShare(shopname, shareStr, location.href, $scope.Member.HeadUrl);
                }



                function IsPC() {
                    var userAgentInfo = navigator.userAgent;

                    var Agents = [
                        "Android", "iPhone",
                        "SymbianOS", "Windows Phone",
                        "iPad", "iPod"
                    ];
                    var flag = true;
                    for (var v = 0; v < Agents.length; v++) {
                        if (userAgentInfo.indexOf(Agents[v]) > 0) {
                            flag = false;
                            break;
                        }
                    }
                    return flag;
                }

                var li_length = $(".recommend li").length;

                (function ($) {
                    $.fn.FontScroll = function (options) {
                        var d = { time: 3000, num: 1 }
                        var o = $.extend(d, options);
                        var li_length = $(".recommend li").length;

                        this.children('ul').addClass('line');
                        var _con = $('.line').eq(0);
                        var _conChildH = _con.children().eq(0).height();//一次滚动高度
                        var _conH = _conChildH * li_length; //滚动总高度
                        var _temp = _conChildH;  //临时变量
                        var _time = d.time;  //滚动间隔
                        _con.clone().insertAfter(_con);//初始化克隆

                        //样式控制
                        var num = d.num;
                        var _p = this.find('li');
                        var allNum = _p.length;

                        var timeID = setInterval(Up, _time);
                        this.hover(
                            function () {
                                clearInterval(timeID)
                            },
                            function () {
                                timeID = setInterval(Up, _time);
                            });

                        function Up() {
                            _con.animate({ marginTop: '-' + _conChildH });

                            num += 1;

                            if (_conH == _conChildH) {
                                _con.animate({ marginTop: '-' + _conChildH }, "normal", over);
                            } else {
                                _conChildH += _temp;
                            }
                        }
                        function over() {
                            _con.attr("style", 'margin-top:0');
                            _conChildH = _temp;
                            num = 1;
                        }
                    }
                })(jQuery);

                if (li_length > 1) {
                    $('#FontScroll').FontScroll({ time: 2500, num: 1 });
                }

                //搜素
                $(".hd-user1,.hd-user2,.hd-user3").on("click", function () {
                    $(".searchbox").show();
                })
                $(".searchbox .cancel").on("click", function () {
                    $(".searchbox").hide();
                })

                // 限时抢购3图样式
                var left_h = parseInt($('.time-limit3 .left').outerHeight(), 10);
                right_h = (left_h - 5) / 2;
                $('.time-limit3 .right .right-info').css('height', right_h + 'px');
                $('.time-limit3 .right .right-info .img').css({ 'width': right_h + 'px', 'height': right_h + 'px' });





                $('.xiang').each(function (i, e) {
                    var li = $(".infor .prod", e),
                        container = $(".box2", e),
                        w = 0;

                    if ($(e).hasClass('nav3')) {
                        w = (container.width() / 10) * 2.3;
                        li.css("width", w + "px");
                        container.css("width", w * li.length + 15 + "px");
                    }
                    if ($(e).hasClass('ml-box2')) {
                        w = (container.width() / 10) * 3.1;
                        li.css("width", w + "px");
                        container.css("width", w * li.length + 15 + "px");
                    }
                    if ($(e).hasClass('manager-list4')) {
                        w = (container.width() / 10) * 4;
                        li.css("width", w + "px");
                        container.css("width", w * li.length + 15 + "px");
                    }

                    new IScroll(e, { eventPassthrough: true, scrollX: true, scrollY: false, preventDefault: false });
                })

                if (localStorage && localStorage.scroll) {
                    scrollTo(0, parseInt(localStorage.scroll));
                    $(".fix4").css("min-height", parseInt(localStorage.scroll) + $(window).height());
                }

                window.onscroll = function () {
                    localStorage.scroll = $(window).scrollTop();
                    $(".fix4").css("min-height", "");
                }



                //data-time 距结束时间 单位:毫秒； data-begin 距开始时间 单位:毫秒
                $(".snapping .shop .btn").each(function (i, e) {
                    var timer = new RunTimer(parseInt($(e).data("time"), 10), parseInt($(e).data("begin"), 10), $(e), i);
                    timer.run();
                })
                function RunTimer(time, begin, box, index) {

                    var _this = this;

                    this.index = index;

                    this.content = $(".snapping .shop")[_this.index];

                    //标签类名，shopping为正在抢购， shop-over为抢购结束
                    this.cName = ["shopping", "shop-go", "shop-over"];

                    this.box = box;

                    this.count = parseInt(this.box.data("count"));

                    this.time = time + new Date().getTime();
                    this.begin = begin + new Date().getTime();

                    this.start = begin > 0 ? this.begin : this.time;

                    //倒计时运行
                    this.run = function () {

                        _this.status();

                        _this.timer = _this.start - new Date().getTime();
                        _this.day = Math.floor(_this.timer / 1000 / 60 / 60 / 24);
                        _this.hour = Math.floor(_this.timer / 1000 / 60 / 60 % 24);
                        _this.minute = Math.floor(_this.timer / 1000 / 60 % 60);
                        _this.second = Math.floor(_this.timer / 1000 % 60);

                        _this.html();

                        if (_this.code !== 2) {
                            _this.t = setTimeout(function () {
                                _this.run();
                            }, 1000);
                        }
                    }

                    // 根据时间 判断运行状态（3个时间段）
                    this.status = function () {
                        //分两种形式，this.begin为距离秒杀开始的时间，this.time为抢购的时间
                        this.start = (this.begin - new Date().getTime()) > 0 ? this.begin : this.time;

                        if (_this.begin - new Date().getTime() > 0) {

                            _this.code = 0;//即将开始

                        } else if (_this.time - new Date().getTime() >= 1000) {

                            _this.code = 1; //正在抢购

                        } else {

                            _this.code = 2; //已结束

                        }
                    }

                    // 输出标签
                    this.html = function () {

                        if (_this.code == 2) {

                        }
                        $(this.content).removeClass("shopping shop-go shop-over").addClass(_this.cName[_this.code]);


                        var h = _this.hour < 10 ? "0" + _this.hour : _this.hour;
                        var m = _this.minute < 10 ? "0" + _this.minute : _this.minute;
                        var s = _this.second < 10 ? "0" + _this.second : _this.second;

                        if (_this.code == 0) {
                            _this.box.html('即将开始');
                        } else if (this.code == 1) {
                            _this.box.html('立即抢购');

                        } else {
                            _this.box.html('抢购结束');
                        }


                    }
                }

                $(".intime.top .time-run").each(function (i, e) {
                    var timer = new RunTime(parseInt($(e).data("time"), 10), parseInt($(e).data("begin"), 10), $(e), i);
                    timer.run();
                })
                // 距结束时间倒计时
                function RunTime(time, begin, box, index) {

                    var _this = this;

                    this.box = box;

                    this.content = box.parents(".top")[0];
                    // console.log($(this.content));
                    this.time = time + new Date().getTime();
                    this.begin = begin + new Date().getTime();

                    this.start = begin > 0 ? this.begin : this.time;

                    //倒计时运行
                    this.run = function () {

                        _this.status();

                        _this.timer = _this.start - new Date().getTime();
                        _this.day = Math.floor(_this.timer / 1000 / 60 / 60 / 24);
                        _this.hour = Math.floor(_this.timer / 1000 / 60 / 60 % 24);
                        _this.minute = Math.floor(_this.timer / 1000 / 60 % 60);
                        _this.second = Math.floor(_this.timer / 1000 % 60);

                        _this.html();

                        if (_this.code !== 2) {
                            _this.t = setTimeout(function () {
                                _this.run();
                            }, 100);
                        }
                    }

                    // 根据时间 判断运行状态（3个时间段）
                    this.status = function () {
                        //分两种形式，this.begin为距离秒杀开始的时间，this.time为抢购的时间
                        this.start = (this.begin - new Date().getTime()) > 0 ? this.begin : this.time;

                        if (_this.begin - new Date().getTime() > 0) {

                            _this.code = 0;//即将开始

                        } else if (_this.time - new Date().getTime() >= 1000) {

                            _this.code = 1; //正在抢购

                        } else {

                            _this.code = 2; //已结束

                        }
                    }

                    // 输出标签
                    this.html = function () {
                        if (_this.code == 2) {

                        }

                        var d = _this.day < 10 ? "0" + _this.day : _this.day;
                        var h = _this.hour < 10 ? "0" + _this.hour : _this.hour;
                        var m = _this.minute < 10 ? "0" + _this.minute : _this.minute;
                        var s = _this.second < 10 ? "0" + _this.second : _this.second;

                        $(".day", this.content).html(d);
                        $(".hour", this.content).html(h);
                        $(".minute", this.content).html(m);
                        $(".second", this.content).html(s);

                        if (_this.code == 2) {

                        } else if (_this.code == 1) {
                            $(".time-condition", this.content).html("距结束");
                        } else {
                            $(".time-condition", this.content).html("距开始");
                        }
                    }
                }
                //拼团倒计时
                $(".pro_box .pt_box .ppc").each(function (i, e) {
                    var timer = new TimeRun(parseInt($(e).data("time"), 10), $(e));
                    timer.run();
                });

                function TimeRun(time, box) {
                    var _this = this;
                    this.box = box;
                    this.start = time + new Date().getTime();

                    this.run = function () {
                        _this.timer = _this.start - new Date().getTime();
                        _this.day = Math.floor(_this.timer / 1000 / 60 / 60 / 24);
                        _this.hour = Math.floor(_this.timer / 1000 / 60 / 60 % 24);
                        _this.minute = Math.floor(_this.timer / 1000 / 60 % 60);
                        _this.second = Math.floor(_this.timer / 1000 % 60);
                        _this.html();
                        this.t = setTimeout(function () {
                            _this.run();
                        }, 100);
                    }

                    this.html = function () {
                        if (_this.timer <= 0) {
                            _this.day = 00;
                            _this.hour = 00;
                            _this.minute = 00;
                            _this.second = 00;

                        };
                        var cont = $("span", _this.box);
                        var d = _this.day,
                              h = _this.hour < 10 ? "0" + _this.hour : _this.hour,
                              m = _this.minute < 10 ? "0" + _this.minute : _this.minute,
                              s = _this.second < 10 ? "0" + _this.second : _this.second;

                        $(".time0", this.box).html(d);
                        $(".time1", this.box).html(h);
                        $(".time2", this.box).html(m);
                        $(".time3", this.box).html(s);
                    }

                }

                // duobao1
                $('.duobao .jindu .left').each(function (i, e) {
                    var jindu = parseFloat($('i', e).text().split('%'));
                    $('.color', e).css('width', jindu + '%');
                })
                // duobao2
                $('.jindu .jindu-det .lr').each(function (i, e) {
                    var all_num = parseInt($('.left i', e).text(), 10),
                        sy_num = parseInt($('.right i', e).text(), 10),
                        bg_width = $(e).prev('.bg').width();
                    color_width = (all_num - sy_num) / all_num * bg_width;
                    if (bg_width == color_width) {
                        $(e).prev('.bg').children('.color').css('border-radius', '9px');
                    }
                    $(e).prev('.bg').children('.color').css('width', color_width + 'px');

                })
                $timeout(function () {
                    $rootScope.KeepScroll(".fix4");
                }, 100);

            });

        }).error(function (response) {
            if (response.Message) {
                alert(response.Message);
            }
        }
        );
        $scope.Sys = function () {
            wx.scanQRCode({
                needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
                success: function (res) {

                    var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
                    var arr = result.split(',');
                    var code = arr[0];
                    if (arr.length > 1) {
                        code = arr[1];
                    }

                    $state.go('shop.product', { shopno: $scope.Member.ShopNo, bc: code });
                }
            });
        }

        $scope.InviteUrl = function () {
            $http.post("/shop/inviteurl", { ShopNo: $scope.Member.ShopNo })
                .success(function (response) {
                    var m1 = response.M;
                    var r1 = response.R;
                    $state.go("shop.authgift", { m: m1, r: r1 });
                    // window.location.href=response.Url;
                })
                .error(function (response) {
                    if (response.Message.indexOf('零售') > 0) {
                        alert('加入方式为零售授权');
                    } else {
                        alert(response.Message);
                    }
                });
        }



        $scope.Favorite = function (sku, id) {
            $http.post('/Favorite', { Type: 2, ShopNo: $scope.Member.ShopNo, Sku: sku }).success(function (response) {
                if (response) {
                    document.getElementById(id + "_img").src = "http://cdn.xsmore.com/Images/zmkm/collected.png" + "?timestamp=" + Date();

                    var num = $("#" + id + "_num").html();
                    $("#" + id + "_num").html(parseInt(num) + 1);
                } else {
                    document.getElementById(id + "_img").src = "http://cdn.xsmore.com/Images/zmkm/st-1.png" + "?timestamp=" + Date();

                    var num = $("#" + id + "_num").html();
                    $("#" + id + "_num").html(num - 1);
                }
                //  $scope.Favorited = response;
            });
        };

        $scope.Search = function () {
            if (!$scope.SKeyWords) {
                return false;
            }
            $state.go('shop.productlist', { keywords: $scope.SKeyWords, shopno: $scope.Member.ShopNo });
        }

        $scope.GetUrl = function (model) {
            if (model) {
                var type = model.SlickType;
                var aid = model.ActivityId;
                var url = model.Url;
                switch (type) {
                    case 1: //商品分类
                        return "#/shop/category/?shopno=" + $scope.Member.ShopNo;
                    case 2: //购物车
                        return "#/shop/cart/" + $scope.Member.ShopNo;
                    case 3: //会员中心
                        return "#/customer/";
                    case 4: //限时特惠
                        return "#/shop/spike/" + $scope.Member.ShopNo;
                    case 5: //专题列表
                        return "#/shop/wordtopiclist/" + $scope.Member.ShopNo;
                    case 6: //营销活动
                        if (model.ActivityType == 8) {
                            return "#/shop/activitycoupon/?id=" + aid + "&mid=" + $scope.Member.Id;
                        }
                        return "#/shop/activity/" + $scope.Member.ShopNo + "/" + aid;
                    case 7: //新品首发
                        return "/#/shop/productlist/" + $scope.Member.ShopNo + "?fresh=true";
                    case 8: //自定义链接
                        if (url.indexOf('weixin.qq.com' > -1) && url.indexOf('wechat_redirect') < 0) {
                            url = url + '#wechat_redirect';
                        }
                        if (!url || url === "#wechat_redirect") {
                            return "";
                        }
                        return url;
                    case 11:
                        return "";
                    default:
                        return "/#/";
                }
            }

        };


        $scope.GetTitle = function (model, showtittle) {
            if (!model.MainTitle && !model.SubTitle) {
                return "";
            }
            var isshowtittle = true;
            if (showtittle == undefined) {
                isshowtittle = true;
            } else if (showtittle.toString() == "1" || showtittle.toString() == "true") {
                isshowtittle = false;
            }
            if (!isshowtittle) {
                return "";
            }

            var html = "";
            var mainTitle = $filter('limitTo')(model.MainTitle, 7, 0);
            var subTitle = $filter('limitTo')(model.SubTitle, 15, 0);
            html = html.concat("<div class='style-title-type " + $scope.TitleBg + "'>");
            html = html.concat("<div class='sport-hd-1'>" +
                "<div class='sport-hd'>" +
                "<span class='txt'>" + mainTitle + "</span>" +
                "</div>" +
             (subTitle ? "<div class='sport-1'>" + subTitle + "</div>" : "") +
                "</div>" +
                "<div class='sport-hd-2'>" +
                "<img src='http://cdn.xsmore.com/Images/zmkm/fit/title-2.png'>" +
                "<div class='hd-txt'>" +
                "<p class='hd-txt-1'>" + mainTitle + "</p>" +
                (subTitle ? "<p class='hd-txt-2'>" + subTitle + "</p>" : "") +
                "</div>" +
                "</div>" +
                "<div class='sport-hd-3'>" +
                "<img src='http://cdn.xsmore.com/Images/zmkm/fit/title-3.jpg'>" +
                "<div class='hd-txt'>" +
                "<p class='hd-txt-1'>" + mainTitle + "</p>" +
                (subTitle ? "<p class='hd-txt-2'>" + subTitle + "</p>" : "") +
                "</div>" +
                "</div>" +
                "<div class='sport-hd-4 theme-bg'>" +
                "<img src='http://cdn.xsmore.com/Images/zmkm/fit/title-4.png'>" +
                "<div class='hd-txt theme-bg'>" +
                "<p class='hd-txt-1'>" + mainTitle + "</p>" +
               (subTitle ? "<p class='hd-txt-2'>" + subTitle + "</p>" : "") +
                "</div>" +
                "<span class='arrow theme-bg'></span>" +
                "</div>" +
                "<div class='sport-hd-5 theme-bg'>" +
                "<img src='http://cdn.xsmore.com/Images/zmkm/fit/title-5.png'>" +
                "<div class='hd-txt theme-bg'>" +
                "<p class='hd-txt-1'>" + mainTitle + "</p>" +
                 (subTitle ? "<p class='hd-txt-2'>" + subTitle + "</p>" : "") +
                "</div>" +
                "</div>" +
                "<div class='sport-hd-6 theme-bg'>" +
                "<img src='http://cdn.xsmore.com/Images/zmkm/fit/title-6.png'>" +
                "<div class='hd-txt theme-bg'>" +
                "<p class='hd-txt-1'>" + mainTitle + "</p>" +
               (subTitle ? "<p class='hd-txt-2'>" + subTitle + "</p>" : "") +
                "</div>" +
                "</div>" +
                "<div class='sport-hd-7'>" +
                "<span class='hd-icon'><img src='http://cdn.xsmore.com/Images/zmkm/zmkm-title-left.png'></span>" +
                "<div class='hd-icon hd-txt'>" +
                "<p class='hd-txt-1'>" + mainTitle + "</p>" +
                    "<p class='hd-txt-2'>" + subTitle + "</p>" +
                "</div>" +
                    "<span class='hd-icon'><img src='http://cdn.xsmore.com/Images/zmkm/zmkm-title-right.png'></span>" +
                "</div>" +
                "<div class='sport-hd-8'>" +
                "<img src='http://cdn.xsmore.com/Images/zmkm/zmkm-title-8.png'>" +
                "<div class='hd-txt'>" +
                "<p class='hd-txt-1'>" + mainTitle + "</p>" +
                    "<p class='hd-txt-2'>" + subTitle + "</p>" +
                    "</div>" +
                "</div>" +
                "<div class='sport-hd-9 theme-bg'>" +
                "<img src='http://cdn.xsmore.com/Images/zmkm/zmkm-title-9.png'>" +
                "<div class='hd-txt'>" +
                "<p class='hd-txt-1 theme-color'>" + mainTitle + "</p>" +
                    "<p class='hd-txt-2'>" + subTitle + "</p>" +
                    "</div>" +
                "</div>" +
                "<div class='sport-hd-10 clearfix'>" +
                "<span class='hd-border theme-bg'></span>" +
                "<span class='hd-txt-1'>" + mainTitle + "</span>" +
                    "<span class='hd-txt-2'>" + subTitle + "</span>" +
                "</div>" +
                "<div class='sport-hd-11 clearfix'>" +
                "<span class='hd-border theme-bg'></span>" +
                "<span class='hd-txt-1 theme-color'>" + mainTitle + "</span>" +
                    "<span class='hd-txt-2'>" + subTitle + "</span>" +
                "</div>" +
                "<div class='sport-hd-12 clearfix'>" +
                "<span class='hd-txt-1'>" + mainTitle + "</span>" +
                "<img src='http://cdn.xsmore.com/Images/zmkm/zmkm-title-10.png'>" +
                    "<span class='hd-txt-2'>" + subTitle + "</span>" +
                "</div>" +
                "<div class='sport-hd-13 clearfix'>" +
                "<span class='hd-txt-1'>" +
                    "<img src='http://cdn.xsmore.com/Images/zmkm/zmkm-title-11.png'>&nbsp;&nbsp;" + mainTitle + "&nbsp;&nbsp;<img src='http://cdn.xsmore.com/Images/zmkm/zmkm-title-11.png'>" +
                "</span>" +
                "<span class='hd-txt-2'>" + subTitle + "</span>" +
                "</div>");


            html = html.concat("</div>");

            return html;
        }
    }
]);



App.controller('ShopController',
  ['$rootScope', '$scope', '$state',  '$window',  '$timeout',    'cfpLoadingBar',  '$location', '$compile', '$http',
  function ($rootScope, $scope, $state,  $window,  $timeout,    cfpLoadingBar,  $location, $compile, $http) {
      "use strict";
      $rootScope.scrollPos = {}; // scroll position of each view

      $(window).on('scroll', function () {
          if ($rootScope.okSaveScroll) { // false between $routeChangeStart and $routeChangeSuccess
              $rootScope.scrollPos[$location.path()] = $(window).scrollTop();
              //console.log($scope.scrollPos);
          }
      });

      $rootScope.scrollClear = function (path) {
          $rootScope.scrollPos[path] = 0;
      }

      // Loading bar transition
      // ----------------------------------- 
      var thBar;
      $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
          $rootScope.okSaveScroll = false;
          $rootScope.ChangeTitle("");
          if ($('.wrapper > section').length) // check if bar container exists
              thBar = $timeout(function () {
                  cfpLoadingBar.start();
              }, 0); // sets a latency Threshold        
          //document.querySelector("head").innerHTML = metas;
          //$rootScope.metabcy = "width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0";
      });
      $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
          //$timeout(function () { // wait for DOM, then restore scroll position
          //    console.log($location.path());
          //    console.log($scope.scrollPos[$location.path()]);

          $rootScope.lashState = fromState;
          if ($state.current.title == "mallname") {
              $rootScope.ChangeTitle($rootScope.app.name);
          } else {
              $rootScope.ChangeTitle($state.current.title);
          }
          //}, 0);
          event.targetScope.$watch("$viewContentLoaded", function () {
              $timeout.cancel(thBar);
              cfpLoadingBar.complete();
          });
          if (toState.name.indexOf('shop.') > -1 && toState.data && !toState.data.noshare) {
              if ($rootScope.app && $rootScope.app.IsOpen === false) {
                  $state.go('message', { msg: '店铺关张中..... ' }, { location: 'replace' });
              }
              //  wx.ready(function () {
              wx.showOptionMenu();
              // })
          } else {
              //  wx.ready(function () {
              //  wx.hideOptionMenu();
              // })
          }
      });


      // Hook not found
      $rootScope.$on('$stateNotFound',
        function (event, unfoundState, fromState, fromParams) {
            //  console.log(unfoundState.to); // "lazy.state"
            // console.log(unfoundState.toParams); // {a:1, b:2}
            // console.log(unfoundState.options); // {inherit:false} + default options
        });
      // Hook error
      $rootScope.$on('$stateChangeError',
        function (event, toState, toParams, fromState, fromParams, error) {
            console.log(error);
        });



      $rootScope.currTitle = $state.current.title;
      $rootScope.pageTitle = function () {
          var title = $rootScope.app.name + ' - ' + ($rootScope.currTitle || $rootScope.app.description);
          document.title = title;
          return title;
      };
    //  $scope.colorByName = colors.byName;

      // Hides/show user avatar on sidebar
      $scope.toggleUserBlock = function () {
          $scope.$broadcast('toggleUserBlock');
      };

      $scope.gopage = function (url) {
          $state.go(url);
      }



     

      // cancel click event easily
      $rootScope.cancel = function ($event) {
          $event.stopPropagation();
      };

      $rootScope.geturl = function () {
          var options = {
              padding: 10,   //二维码四边空白，默认为10px
              width: 256,  //二维码图片宽度，默认为256px
              height: 256,  //二维码图片高度，默认为256px
              correctLevel: QRErrorCorrectLevel.L,    //二维码容错level，默认为高
              background: "#ffffff",    //二维码颜色
              foreground: "#000000"     //二维码背景颜色
          }
          var imgBase64 = jrQrcode.getQrBase64($location.absUrl(), options);
          return imgBase64;
          //var url = "http://qr.liantu.com/api.php?text=" + encodeURIComponent($location.absUrl());
          //return url;

      }
      $rootScope.GetBase64 = function (url) {

      }
      if (!$rootScope.ewm) {
          $timeout(function () {
              var qrurl = "http://cdn.xsmore.com/Images/zmkm/zmkm-rwm.jpg";
              $http.post("/shop/mall").success(function (response) {

                  if (response.WxQrcodeUrl) {
                      qrurl = "/shop/getbase64img/?url=" + encodeURIComponent(response.WxQrcodeUrl);

                  }
                  var a = function () { return (65536 * (1 + Math.random()) | 0).toString(16).substring(1) };
                  var guid = a() + a() + "-" + a() + "-" + a() + "-" + a() + "-" + a() + a() + a();
                  var html = '<div ng-show="$state.current.data.ShowQrCode" style="width: 100%;text-align: center;font-size: 12px;padding: 15px 0;margin-top: 20px;background: #fff;color: #666;"><i id="rwm-' + guid + '">关注公众号</i>&nbsp;&nbsp;<i id="rwm-1-' + guid + '">本页二维码</i></div>';
                  var tip = '<div id="tip-' + guid + '" style="position:fixed;left:0;top:0;width:100%;height:100%;display:none;z-index:111;">' +
                      '<div class="filter" style="position:absolute;left:0;top:0;width:100%;height:100%;background:rgba(0,0,0,.8)"></div>' +
                      '<div style="position: absolute;width: 60%;max-width: 480px;top: 15%;left: 50%;-webkit-transform: translateX(-50%);transform: translateX(-50%);">' +
                      '<p style="text-align:center;margin-bottom:1.5rem;font-size:1.4rem;color:#fff;">长按识别二维码关注我们</p>' +
                      '<div style="background:#fff;margin:0 auto;width:80%"><img style="display:block;width:100%;" id="gzhewm" ></div>' +
                      '</div>' +
                      '</div>' +
                      '<div id="tip-1-' + guid + '" style="position:fixed;left:0;top:0;width:100%;height:100%;display:none;z-index:111;">' +
                      '<div class="filter" style="position:absolute;left:0;top:0;width:100%;height:100%;background:rgba(0,0,0,.8)"></div>' +
                      '<div style="position: absolute;width: 60%;max-width: 480px;padding: 10px;top: 15%;left: 50%;-webkit-transform: translateX(-50%);transform: translateX(-50%);">' +
                      '<p style="text-align:center;line-height: 1.8rem;margin-bottom:1.5rem;font-size:1.4rem;color:#fff;">通过微信【扫一扫】功能<br>扫描二维码访问页面</p>' +
                      //'<div style="padding:10px;background:#fff;margin:0 auto;width:80%"><img style="display:block;width:100%;" ng-src="{{geturl()}}"></div>' +
                      '<div style="padding:10px;background:#fff;margin:0 auto;width:80%"><img id="qrimg" style="display:block;width:100%;" ></div>' +

                      '</div>' +
                      '</div>';

                  angular.element(document.getElementsByTagName('body')).append($compile(html + tip)($scope));


                  $("#rwm-" + guid).on("click", function () {
                      $("#gzhewm").attr("src", qrurl);
                      $("#tip-" + guid).fadeIn();
                  })

                  $("#rwm-1-" + guid).on("click", function () {

                      var options = {
                          padding: 10,   //二维码四边空白，默认为10px
                          width: 256,  //二维码图片宽度，默认为256px
                          height: 256,  //二维码图片高度，默认为256px
                          correctLevel: QRErrorCorrectLevel.L,    //二维码容错level，默认为高
                          background: "#ffffff",    //二维码颜色
                          foreground: "#000000"     //二维码背景颜色
                      }
                      var imgBase64 = jrQrcode.getQrBase64($location.absUrl(), options);
                      $("#qrimg").attr("src", imgBase64);

                      $("#tip-1-" + guid).fadeIn();
                  })

                  $("#tip-" + guid + " .filter").on("click", function () {
                      $("#tip-" + guid).fadeOut();
                  })

                  $("#tip-1-" + guid + " .filter").on("click", function () {
                      $("#tip-1-" + guid).fadeOut();
                  })
                  $rootScope.ewm = true;
              });


          }
              , 0, false
      );
      }

  }]);



App.filter('propsFilter', function () {
    return function (items, props) {
        var out = [];

        if (angular.isArray(items)) {
            items.forEach(function (item) {
                var itemMatches = false;

                var keys = Object.keys(props);
                for (var i = 0; i < keys.length; i++) {
                    var prop = keys[i];
                    var text = props[prop].toLowerCase();
                    if (item[prop].toString().toLowerCase().indexOf(text) !== -1) {
                        itemMatches = true;
                        break;
                    }
                }

                if (itemMatches) {
                    out.push(item);
                }
            });
        } else {
            // Let the output be the input untouched
            out = items;
        }

        return out;
    };
});


App.directive('ngClickD', function ($rootScope) {
    return {
        scope: {
            ngClickD: '&'
        },
        link: function (scope, iElement, iAttrs) {
            iElement.bind('click', function () {
                if (iElement.attr('running') === 'running') {
                    return;
                }
                $rootScope.spinner.on();
                $rootScope.tospinner = true;
                iElement.attr('running', 'running');
                try {
                    scope.ngClickD()
                        .finally(function () {
                            $rootScope.spinner.off();
                            $rootScope.tospinner = false;
                            iElement.removeAttr('running');

                        });
                } catch (e) {
                    $rootScope.spinner.off();
                    $rootScope.tospinner = false;
                    iElement.removeAttr('running');

                } finally {

                }


            });
        }
    };
});
App.directive('myEnter', function () {
    return function (scope, element, attrs) {
        element.bind("keydown keypress", function (event) {
            if (event.which === 13) {
                scope.$apply(function () {
                    scope.$eval(attrs.myEnter);
                });

                event.preventDefault();
            }
        });
    };
});
//默认图片
App.directive('nullSrc', function ($rootScope) {
    var nullSrc = {
        link: function postLink(scope, iElement, iAttrs) {
            var src = iAttrs.nullSrc ? iAttrs.nullSrc : "http://cdn.xsmore.com/Images/zmkm/class.png";
            iElement.bind('error', function () {
                angular.element(this).attr("src", src);
            });
        }
    }
    return nullSrc;
});

App.directive('back', ['$window', function ($window) {
    return {
        restrict: 'A',
        link: function (scope, elem, attrs) {
            elem.bind('click', function () {
                $window.history.back();
            });
        }
    };
}]);
App.directive("ngNulldata",
    function () {
        return {
            scope: {
                datasource: '=datasource'
            },
            link: function (scope, element, attrs) {
                scope.$watch('datasource',

                    function (newVal, oldValue) {
                        if (scope.datasource.length === 0) {
                            element.html('<div class=\"zmkm-nodata\">' +
                                '<img src="http://cdn.xsmore.com/Images/zmkm/wujieguo.png">' +
                                '<p class="zmkm-nodata-txt">暂无数据</p>' +
                                '</div>');
                        }
                    });
            }

        };
    });
App.directive('ngClickD2', function ($parse) {
    return {
        restrict: 'A',
        compile: function ($element, attr) {
            var fn = $parse(attr.disableOnPromise);
            return function clickHandler(scope, element, attrs) {
                element.on('click', function (event) {
                    $element.addClass('disabled');
                    scope.$apply(function () {
                        if (event) {
                            fn(scope, { $event: event }).finally(function () {
                                $element.removeClass('disabled');
                            });
                        } else {
                            $element.removeClass('disabled');
                        }
                    });
                });
            };
        }
    };
});


App.factory('LookExpressInfo', ['$http', function ($http) {

    return {
        get: function (orderno) {
            $http.post('/platformOrder/lookExpressInfo', { OrderNo: orderno }).success(function (data) {
                return data;
            });
        }
    };

}]);


App.factory('ShopProduct', function ($http) {
    var ShopProduct = function (data, fun) {

        this.busy = false;
        this.after = '';
        this.requestData = data;
        this.requestData.skip = 0;
        this.requestData.take = data.Take;
        this.all = false;
        this.loadinfo = fun;
    };

    ShopProduct.prototype.nextPage = function () {
        if (this.busy) return;
        if (this.all) {
            return;
        }
        this.busy = true;

        var url = "/product/list";
        $http.post(url, this.requestData).success(function (response) {
            if (!this.items) {
                this.items = [];
            }
            var items = response.Products.Results;
            for (var i = 0; i < items.length; i++) {
                this.items.push(items[i]);
            }
            this.requestData.skip = this.items.length;
            this.busy = false;
            this.all = items.length < this.requestData.Take || items.length === response.Products.Total;
            this.loadinfo(response);
        }.bind(this));
    };

    return ShopProduct;
});

App.factory('RedditWithFunc', function ($http) {
    var RedditWithFunc = function (data, fun, url) {
        this.busy = false;
        this.after = '';
        this.requestData = data;
        this.requestData.skip = 0;
        this.requestData.take = data.Take;
        if (!this.requestData.Take) {
            this.requestData.Take = 20;
        }
        this.all = false;
        this.loadinfo = fun;
        this.url = url;
    };

    RedditWithFunc.prototype.nextPage = function () {
        if (this.busy) return;
        if (this.all) {
            return;
        }
        this.busy = true;
        $http.post(this.url, this.requestData).success(function (response) {
            if (!this.items) {
                this.items = [];
            }
            var items = response.ModelList.Results;
            for (var i = 0; i < items.length; i++) {
                this.items.push(items[i]);
            }
            this.requestData.skip = this.items.length;
            this.busy = false;
            this.all = items.length < this.requestData.Take || items.length === response.ModelList.Total;
            this.loadinfo(response);
        }.bind(this));
    };
    return RedditWithFunc;
});


App.factory('Reddit',
    function ($http) {
        var Reddit = function (url, data, callback) {

            //  this.items = [];
            this.busy = false;
            this.after = '';
            this.requestData = data;
            this.requestData.skip = 0;
            if (!this.requestData.Take) {
                this.requestData.Take = 10;
            }
            this.all = false;
            if (callback) {
                this.callBack = callback;
            }
            this.total = 0;
            this.url = url;
        };

        Reddit.prototype.nextPage = function (stop) {
            if (stop) {
                return;
            }
            if (this.busy) return;
            if (this.all) {
                return;
            }
            this.busy = true;
            $http.post(this.url, this.requestData)
                .success(function (response) {
                    if (!this.items) {
                        this.items = [];
                    }
                    var items = response.Results;
                    this.total = response.Total;
                    for (var i = 0; i < items.length; i++) {
                        this.items.push(items[i]);
                    }
                    if (this.items.length == 0) {
                        this.nodata = true;
                    }
                    this.requestData.skip = this.items.length;
                    this.busy = false;
                    if (response.Total) {
                        this.all = this.requestData.skip >= response.Total;
                    } else {
                        this.all = items.length < this.requestData.Take || items.length === this.total;
                    }
                    if (this.callBack) {
                        this.callBack(response);
                    }
                }.bind(this));
        };

        return Reddit;
    });

App.factory('mallStyleService', ['$rootScope', 'Reddit', function ($rootScope, Reddit) {



    var GetFunction = function (model, $scope) {
        if (model) {
            var linkType = model.LinkType;
            if (linkType == 1) {
                if (model.Link.indexOf('weixin.qq.com' > -1) && model.Link.indexOf('wechat_redirect') < 0) {
                    model.Link = model.Link + '#wechat_redirect';
                }
                if (!model.Link || model.Link === "#wechat_redirect") {
                    return "";
                }
                return "ng-click='GoUrl(\"" + model.Link + "\")'";
            } else {
                var type = model.ServerLinkType;
                $scope.UiSrefIds.push(model.ServerLinkId);
                var idindex = $scope.UiSrefIds.length - 1;
                $scope.UiSrefSkus.push(model.Sku);

                switch (type.toString()) {
                    case "0": //品牌
                        if (!idindex) return "";
                        return "ui-sref='shop.productlist({shopno:Member.ShopNo,cateId:0,brand:UiSrefIds[" + idindex + "]})'";
                    case "1": //商品分类
                        return "ui-sref='shop.productlist({shopno:Member.ShopNo,cateId:UiSrefIds[" + idindex + "]})'";
                    case "2": //在售商品
                        var length2 = $scope.UiSrefSkus.length - 1;
                        return "ui-sref='shop.product({sku:UiSrefSkus[" + length2 + "],shopno:Member.ShopNo})'";
                    case "3": //营销活动
                        if (model.ActivityType == 8) {
                            return "ui-sref='shop.activitycoupon({id:UiSrefIds[" + idindex + "],mid:Member.Id})'";
                        } else if (model.ActivityType == 10) {
                            return "ui-sref='shop.memberclientsign({shopno:Member.ShopNo})'";
                        }
                        return "ui-sref='shop.activity({id:UiSrefIds[" + idindex + "],shopno:Member.ShopNo})'";

                    case "4": //功能
                        switch (model.ServerLinkId.toString()) {
                            case "1": //首页
                                return "ui-sref='shop.index2({shopno:Member.ShopNo})'";
                            case "2": //全部商品
                                return "ng-click=GoUrl('/#/shop/category/?shopno=" + $scope.Member.ShopNo + "')";
                            case "3": //购物车
                                return "ui-sref='shop.cart({shopno:Member.ShopNo})'";
                            case "4": //会员中心
                                return "ui-sref='customer.center'";
                            case "5": //扫一扫
                                return "ng-click=Sys()";
                            case "6": //我要开店
                                return "ng-click='InviteUrl()'";
                            case "9": //会员中心
                                return "ui-sref='customer.allTopic'";
                            case "10": //积分换购
                                return "ui-sref='shop.pointexchangelist({shopno:Member.ShopNo})'";
                            default:
                                return "";
                        }
                    case "5": //h5页面
                        return "ng-click=GoUrl('" + $rootScope.PCUrl + "Views/TemplatePromotion/CustomTemplatesH5Show/H5Model/H5ModelPage.html?id=" + $scope.UiSrefIds[idindex] + "&mallId=" + $rootScope.app.mallid + "&nothing=0')";
                    case "6": //文章
                        if (!$scope.UiSrefIds[idindex]) {
                            return "";
                        }
                        return "ui-sref='shop.artical({id:" + $scope.UiSrefIds[idindex] + "})'";
                    case "7":
                        return "ng-click=GoUrl('" + GetGameUrl($scope, $scope.UiSrefIds[idindex]) + "')";
                    case "8":
                        return "ui-sref='shop.otherPageLookOver({Id:" + $scope.UiSrefIds[idindex] + ",shopno:Member.ShopNo})'";
                    case "9":
                        return "ui-sref='shop.video({id:" + $scope.UiSrefIds[idindex] + ",shopno:Member.ShopNo})'";
                    default:
                        return "";
                }
            }
        }
    };
    var GetGameUrl = function ($scope, id) {
        var games = $scope.games;
        for (var i = 0; i < games.length; i++) {
            if (games[i].Id == id) {
                var gameurl = games[i].Url + "?gid=" + id + "&mid=" + $scope.Mall.Id;

                return gameurl;
            }
        }
        return "#";
    };
    var GetNotifyUrl = function (value) {
        if (value.type == "1") {
            return "href='" + value.link + "'";
        } else {
            if (!value.mesId) {
                return "";
            }
            return "ui-sref='shop.artical({id:" + value.mesId + "})'";
        }
    };
    var getactivitysref = function (activity) {
        var uisref = "shop.activity({shopno:Member.ShopNo,id:" + activity.ActivityId + "})";
        if (activity.ActivityType == 8) {
            uisref = "shop.activitycoupon({mid:Member.Id,id:" + activity.ActivityId + "})";
        } else if (activity.ActivityType == 10) {
            uisref = "shop.memberclientsign({shopno:Member.ShopNo})";
        }
        return uisref;
    };
    var GetHtml = function (dc, $scope) {
        var html = "";
        angular.forEach(dc, function (value, dcindex) {
            switch (value.MouduleType) {
                case 1:

                    switch (value.MouduleContent.ShopDecorateSearch.Type) {
                        case 1:
                            html = html.concat("  <div class='hd-user1 clearfix theme-bg'>" +
                                "<img src='" + $scope.Member.HeadUrl + "'>" +
                                "  <p class='name'>{{Member.ShopName}}</p>" +
                                " <span class='search'><img src='http://cdn.xsmore.com/Images/zmkm/search.png'>搜索</span>" +
                                "  </div>");
                            break;
                        case 0:
                            html = html.concat("  <div class='hd-user2 boxz'>" +
                                "<div class='search2 boxz'>" +
                                "  <input type='text' class='boxz' ng-model='SKeyWords' my-enter='Search()' readonly='readonly'>" +
                                " <span class='not'><img src='http://cdn.xsmore.com/Images/zmkm/sy-search-02.png'><i>搜索</i></span>" +
                                "  </div></div>");
                            break;
                        case 2:
                            html = html.concat("  <div class='hd-user3 boxz'>" +
                                "<div class='search3 boxz'>" +
                                "  <input type='text' class='boxz' placeholder='搜索' ng-model='SKeyWords' my-enter='Search()' readonly='readonly'>" +
                                " <span class='not'></span>" +
                                "  </div></div>");
                            break;
                    }
                    break;
                case 2:
                    html = html.concat("<div class=\"well-recco clearfix\">" +
                        "<div class=\"name theme-color\">" + value.MouduleContent.ShopDecorateShopNotify.Content + "</div>" +
                        "<div class=\"recommend\" id=\"FontScroll\">" +
                        "<ul >");
                    angular.forEach(value.MouduleContent.ShopDecorateShopNotify.ExtendInfo.info.list, function (v2, index) {
                        html = html.concat("<li class=\"recco\">" +
                            "<a " + GetNotifyUrl(v2) + "><p class=\"infor\">" + v2.txt + "</p></a>" +
                            "</li>");
                    });
                    html = html.concat("</ul>" +
                        "</div>" +
                        "</div>");

                    break;
                case 3:
                    switch (value.MouduleContent.ShopDecorateSlick[0].SlideType) {
                        case 1:
                            html = html.concat(" <div class='slick1'>");
                            angular.forEach(value.MouduleContent.ShopDecorateSlick, function (v3, index) {
                                html = html.concat("<div><a " + GetFunction(v3, $scope) + " ><img src='" + $rootScope.ImgHost + v3.Img + "' alt=''></a></div>");
                            });
                            html = html.concat("</div>");
                            break;
                        case 3:
                            html = html.concat(" <div class='slick2'>");
                            angular.forEach(value.MouduleContent.ShopDecorateSlick, function (v3, index) {
                                html = html.concat("<div><a " + GetFunction(v3, $scope) + " ><img src='" + $rootScope.ImgHost + v3.Img + "' alt=''></a></div>");
                            });
                            html = html.concat("</div>");
                            break;
                        case 2:
                            html = html.concat(" <div class='slick3'>");
                            angular.forEach(value.MouduleContent.ShopDecorateSlick, function (v3, index) {
                                html = html.concat("<div><a " + GetFunction(v3, $scope) + " ><img src='" + $rootScope.ImgHost + v3.Img + "' alt=''></a></div>");
                            });
                            html = html.concat("</div>");
                            break;
                        case 0:
                            html = html.concat(" <div class='slick4'>");
                            //console.log(value.MouduleContent.ShopDecorateSlick);
                            angular.forEach(value.MouduleContent.ShopDecorateSlick, function (v3, index) {
                                html = html.concat("<div><a " + GetFunction(v3, $scope) + " ><img src='" + $rootScope.ImgHost + v3.Img + "' alt=''></a></div>");
                                //console.log($rootScope.ImgHost + v3.Img);
                            });
                            html = html.concat("<span class='suoyin'><i class='small'>1</i>/<i class='big'>15</i></span>");
                            html = html.concat("</div>");

                            break;
                    }
                    break;
                    //快捷人口
                case 4:
                    switch (value.MouduleContent.ShopDecorateEntrance[0].SlideType) {
                        case 1:
                            html = html.concat("<div class='nav '>");
                            angular.forEach(value.MouduleContent.ShopDecorateEntrance, function (v4, index) {
                                html = html.concat("    <a " + GetFunction(v4, $scope) + "><img src='" + $rootScope.ImgHost + v4.ImgUrl + "'>" + v4.Name + "</a>");
                            });
                            html = html.concat("</div>");
                            break;
                        case 0:
                            html = html.concat("<ul class='nav2 clearfix'>");
                            angular.forEach(value.MouduleContent.ShopDecorateEntrance, function (v4, index) {
                                html = html.concat("    <li><a " + GetFunction(v4, $scope) + "><span class='img'><img src='" + $rootScope.ImgHost + v4.ImgUrl + "'></span>" + v4.Name + "</a></li>");
                            });
                            html = html.concat("</ul>");
                            break;
                        case 2:
                            html = html.concat("<div class='xiang nav3'><div class='box2'><ul class='infor clearfix'>");
                            angular.forEach(value.MouduleContent.ShopDecorateEntrance, function (v4, index) {
                                html = html.concat("    <li class='prod'><a class='bsx' " + GetFunction(v4, $scope) + "><span class='img'><img src='" + $rootScope.ImgHost + v4.ImgUrl + "'></span><p class='name'>" + v4.Name + "</p></a></li>");
                            });
                            html = html.concat("</ul></div></div>");
                            break;
                    }
                    break;
                case 5:
                    $scope.ShopNotify = value.MouduleContent.ShopDecorateShopRecruit.ShopNotify;
                    switch (value.MouduleContent.ShopDecorateShopRecruit.Style) {
                        case 0:
                            html = html.concat("<div class='user-info clearfix'>" +
                                " <div class='img'>" +
                                "    <img src='" + $scope.Member.HeadUrl + "' class='hd-pic'>" +
                                "    <img src='http://cdn.xsmore.com/Images/zmkm/zx.png' class='zx'>" +
                                " </div>" +
                                " <p class='name'>" + $scope.Member.ShopName + "</p>" +
                                " <p class='gg'>公告：{{Member.ShopDesc?Member.ShopDesc:'" + $scope.ShopNotify + "'}}</p>" +
                                "<span class=\"zm-fire\"><img src=\"http://cdn.xsmore.com/Images/zmkm/fire.png\">{{Member.FavCount}}</span>" +
                                "</div>");
                            break;
                        case 1:
                            html = html.concat("<div class='user-info2'>" +
                                " <div class='shop-name'>" +
                                "    <span class='txt'>" + $scope.Member.ShopName + "</span>" +
                                " </div>" +
                                "<div class='shop-notice'>{{Member.ShopDesc?Member.ShopDesc:'" + $scope.ShopNotify + "'}}</div>" +
                                "</div>");
                            break;
                        case 2:
                            html = html.concat("<div class='user-info3'>" +
                                " <div class='top'>" +
                                " <img src='" + $rootScope.ImgHost + value.MouduleContent.ShopDecorateShopRecruit.Image + "' class='img'> " +
                                " <div class='info clearfix'> " +
                                "    <img src='" + $scope.Member.HeadUrl + "' >" +
                                " <p class='name'>" + $scope.Member.ShopName + "</p> " +
                                " </div></div>" +
                                " <p class='notice'>公告：{{Member.ShopDesc?Member.ShopDesc:'" + $scope.ShopNotify + "'}}</p> " +
                                "</div>");
                            break;
                        case 3:
                            html = html.concat("<div class='user-info4'>" +
                                " <div class='top'>" +
                                " <img src='" + $rootScope.ImgHost + value.MouduleContent.ShopDecorateShopRecruit.Image + "' class='img'> " +
                                " <div class='info'> " +
                                "    <img src='" + $scope.Member.HeadUrl + "' >" +
                                " <p class='name'>" + $scope.Member.ShopName + "</p> " +
                                " </div></div>" +
                                " <p class='notice'>公告：{{Member.ShopDesc?Member.ShopDesc:'" + $scope.ShopNotify + "'}}</p> " +
                                "</div>");
                            break;
                    }

                    break;
                case 6:
                    switch (value.MouduleContent.ShopDecorateCreditTerms.CreditType) {
                        case 0:
                            html = html.concat(" <ul class='credit-list'>");
                            angular.forEach(value.MouduleContent.ShopDecorateCreditTerms.CreditContent, function (v6value, index) {
                                html = html.concat("<li><img src='" + (value.MouduleContent.ShopDecorateCreditTerms.CreditImageList[index] == "" ? "http://cdn.xsmore.com/Images/zmkm/promise-gou.png" : $rootScope.ImgHost + value.MouduleContent.ShopDecorateCreditTerms.CreditImageList[index]) + "'>" + v6value + "</li>");
                            });
                            html = html.concat("</ul>");
                            break;
                        case 1:
                            html = html.concat(" <ul class='credit-list2'>");
                            angular.forEach(value.MouduleContent.ShopDecorateCreditTerms.CreditContent, function (v6value, index) {
                                html = html.concat("<li><img src='" + (value.MouduleContent.ShopDecorateCreditTerms.CreditImageList[index] == "" ? "http://cdn.xsmore.com/Images/zmkm/promise-gou.png" : $rootScope.ImgHost + value.MouduleContent.ShopDecorateCreditTerms.CreditImageList[index]) + "'>" + v6value + "</li>");
                            });
                            html = html.concat("</ul>");
                            break;
                    }
                    break;
                case 7: //限时秒杀

                    if (value.MouduleContent.Spikes && value.MouduleContent.Spikes.length > 0) {
                        html = html.concat($scope.GetTitle(value.MouduleContent.ShopDecorateSpike, value.MouduleContent.ShopDecorateSpike.IsShowTitle));
                        html = html.concat(" <div class='intime top clearfix'> ");
                        html = html.concat(" <p class='title'>限时秒杀</p> ");
                        html = html.concat(" <p class='time-run' data-time='" + value.MouduleContent.Spikes[0].Ends + "' data-begin='" + value.MouduleContent.Spikes[0].Begins + "' ><i class='time-condition'>距结束</i><span class='day'>16</span>:<span class='hour'>16</span>:<span class='minute'>16</span>:<span class='second'>16</span></p> ");
                        html = html.concat(" </div> ");

                        //console.log(value.MouduleContent.Spikes);
                        switch (value.MouduleContent.ShopDecorateSpike.Style) {
                            case 0:
                                html = html.concat("<div class=\"xsqg snapping\">");
                                angular.forEach(value.MouduleContent.Spikes, function (v7, index) {
                                    var v7class = "";
                                    switch (v7.ActivityState) {
                                        case '进行中':
                                            v7class = 'shop clearfix';
                                            break;
                                        case '未开始':
                                            v7class = 'shop shopping clearfix';
                                            break;
                                        case '已结束':
                                            v7class = 'shop shop-over clearfix';
                                            break;
                                        default:
                                    }

                                    html = html.concat("<div class='" + v7class + "' ui-sref='shop.product({sku:\"" + v7.ProductSku + "\",shopno:Member.ShopNo})'>" +
                                        "  <div class='img'>" +
                                        "        <img src='" + $rootScope.ImgHost + v7.ProductImgUrl + "' class='pro-pic'>" +
                                        "<img src='http://cdn.xsmore.com/Images/zmkm/sy-122.png'  class='over' ng-if='" + (v7.PreSell) + "'>" +
                                        "<img src='http://cdn.xsmore.com/Images/zmkm/sy-124.png' ng-if='" + (!v7.PreSell && v7.IsDisplay && v7.RealStock <= 0) + "' class='over'>" +
                                        "      </div>" +
                                        "     <p class='name'>" + v7.ProductName + "</p>" +
                                        "     <p class='price'>抢购价<i class='big'>" + v7.Price + "</i>元 <i class='old'>&yen;" + v7.MarketPrice + "</i>" +
                                        "     </p>" +
                                        "    <span class='btn' ng-if='" + (v7.ActivityState == '进行中') + "' data-stock='" + v7.RealStock + "'  data-presell='" + v7.PreSell + "' data-isdisplay='" + v7.IsDisplay + "' data-time='" + v7.Ends + "' data-begin='" + v7.Begins + "' data-count='10' >立即抢购</span>" +
                                        " <span class='btn theme-bg' ng-if='" + (v7.ActivityState == '未开始') + "' data-time='" + v7.Ends + "' data-begin='" + v7.Begins + "' data-count='10'>距秒杀开始&nbsp;<i>00</i>&nbsp;:&nbsp;<i>00</i>&nbsp;:&nbsp;<i>00</i></span> " +
                                        "<span class='btn theme-bg' ng-if='" + (v7.ActivityState == '已结束') + "' data-time='" + v7.Ends + "' data-begin='" + v7.Begins + "' data-count='10'>秒完啦</span>" +
                                        "  </div>");

                                });
                                html = html.concat("  </div>");
                                break;
                            case 1:
                                html = html.concat("<div class=\"xsqg time-limit manager-list4 xiang\">" +
                                    " <div class='box2'><ul class='infor clearfix'> ");
                                angular.forEach(value.MouduleContent.Spikes, function (v7, index) {
                                    var v7class = "prod";
                                    //if (!v7.PreSell && v7.RealStock <= 0) {
                                    //    v7class = 'prod end';
                                    //} else {
                                    //    v7class = 'prod';
                                    //}

                                    html = html.concat(" <li class='" + v7class + "' ><a class='bsx' ui-sref='shop.product({sku:\"" + v7.ProductSku + "\",shopno:Member.ShopNo})'>" +
                                        " <span class='pro-name'>" + v7.ProductName + "</span> " +
                                        "  <span class='img'>" +
                                        "        <img src='" + $rootScope.ImgHost + v7.ProductImgUrl + "' >" +
                                        "<img src='http://cdn.xsmore.com/Images/zmkm/sy-122.png'  class='cover' ng-if='" + (v7.PreSell) + "'>" +
                                        "<img src='http://cdn.xsmore.com/Images/zmkm/sy-124.png' ng-if='" + (!v7.PreSell && v7.IsDisplay && v7.RealStock <= 0) + "' class='cover'>" +
                                        "      </span>" +
                                        " <span class='price'> " +
                                        " <i class='now'>秒杀价<i>" + v7.Price + "</i>元</i> " +
                                        " <i class='even'>售价：<i>&yen;" + v7.MarketPrice + "</i></i> " +
                                        " </span></a></li> ");

                                });
                                html = html.concat("  </ul></div></div>");
                                break;
                            case 2:
                                html = html.concat("<div class=\"xsqg time-limit3 clearfix\">");
                                var lefthtml = "", righthtml = "";

                                var model0 = value.MouduleContent.Spikes[0];
                                if (model0) {
                                    lefthtml = " <div class='left' ui-sref='shop.product({sku:\"" + model0.ProductSku + "\",shopno:Member.ShopNo})'>" +
                                        "<span class='img'><img src='" + $rootScope.ImgHost + model0.ProductImgUrl + "'>" +
                                        "<img src='http://cdn.xsmore.com/Images/zmkm/sy-122.png'  class='cover' ng-if='" + (model0.PreSell) + "'>" +
                                        "<img src='http://cdn.xsmore.com/Images/zmkm/sy-124.png' ng-if='" + (!model0.PreSell && model0.IsDisplay && model0.RealStock <= 0) + "' class='cover'>" +
                                        "</span>" +
                                        "<p class='pro-name'>" + model0.ProductName + "</p>" +
                                        "<p class='price'>秒杀价<i>" + model0.Price + "</i>元</p>" +
                                        "<span class='lock'><img src='http://cdn.xsmore.com/Images/zmkm/lock.png'></span>" +
                                        "</div> ";
                                    var model1 = value.MouduleContent.Spikes[1];
                                    if (model1) {
                                        righthtml += " <div class='right-info top' ui-sref='shop.product({sku:\"" + model1.ProductSku + "\",shopno:Member.ShopNo})'>" +
                                            "<span class='img'><img src='" + $rootScope.ImgHost + model1.ProductImgUrl + "'>" +
                                            "<img src='http://cdn.xsmore.com/Images/zmkm/sy-122.png'  class='cover' ng-if='" + (model1.PreSell) + "'>" +
                                            "<img src='http://cdn.xsmore.com/Images/zmkm/sy-124.png' ng-if='" + (!model1.PreSell && model1.IsDisplay && model1.RealStock <= 0) + "' class='cover'>" +
                                            "</span>" +
                                            "<p class='name2'>" + model1.ProductName + "</p>" +
                                            "<p class='price-n'>秒杀价<i>" + model1.Price + "</i>元</p>" +
                                            "<p class='price-e'>售价：<i>&yen;" + model1.MarketPrice + "</i></p>" +
                                            "</div> ";
                                        var model2 = value.MouduleContent.Spikes[2];
                                        if (model2) {
                                            righthtml += " <div class='right-info bottom' ui-sref='shop.product({sku:\"" + model2.ProductSku + "\",shopno:Member.ShopNo})'>" +
                                                "<span class='img'><img src='" + $rootScope.ImgHost + model2.ProductImgUrl + "'>" +
                                                "<img src='http://cdn.xsmore.com/Images/zmkm/sy-122.png'  class='cover' ng-if='" + (model2.PreSell) + "'>" +
                                                "<img src='http://cdn.xsmore.com/Images/zmkm/sy-124.png' ng-if='" + (!model2.PreSell && model2.IsDisplay && model2.RealStock <= 0) + "' class='cover'>" +
                                                "</span>" +
                                                "<p class='name2'>" + model2.ProductName + "</p>" +
                                                "<p class='price-n'>秒杀价<i>" + model2.Price + "</i>元</p>" +
                                                "<p class='price-e'>售价：<i>&yen;" + model2.MarketPrice + "</i></p>" +
                                                "</div> ";
                                        }
                                    }
                                }

                                html = html.concat(lefthtml + " <div class='right'>" +
                                    "<div class='right-det'> " + righthtml + " </div></div> ");
                                html = html.concat("  </div>");
                                break;
                            case 3:
                                html = html.concat("<div class=\"xsqg time-limit3 time-limit4 clearfix\">");
                                var lefthtml = "", righthtml = "";

                                var model0 = value.MouduleContent.Spikes[0];
                                if (model0) {
                                    lefthtml = " <div class='left' ui-sref='shop.product({sku:\"" + model0.ProductSku + "\",shopno:Member.ShopNo})'>" +
                                        "<span class='img'><img src='" + $rootScope.ImgHost + model0.ProductImgUrl + "'>" +
                                        "<img src='http://cdn.xsmore.com/Images/zmkm/sy-122.png'  class='cover' ng-if='" + (model0.PreSell) + "'>" +
                                        "<img src='http://cdn.xsmore.com/Images/zmkm/sy-124.png' ng-if='" + (!model0.PreSell && model0.IsDisplay && model0.RealStock <= 0) + "' class='cover'>" +
                                        "</span>" +
                                        "<p class='pro-name'>" + model0.ProductName + "</p>" +
                                        "<p class='price'>秒杀价<i>" + model0.Price + "</i>元</p>" +
                                        "<span class='lock'><img src='http://cdn.xsmore.com/Images/zmkm/lock.png'></span>" +
                                        "</div> ";
                                    var model1 = value.MouduleContent.Spikes[1];
                                    if (model1) {
                                        righthtml += " <div class='right-info top' ui-sref='shop.product({sku:\"" + model1.ProductSku + "\",shopno:Member.ShopNo})'>" +
                                            "<span class='img'><img src='" + $rootScope.ImgHost + model1.ProductImgUrl + "'>" +
                                            "<img src='http://cdn.xsmore.com/Images/zmkm/sy-122.png'  class='cover' ng-if='" + (model1.PreSell) + "'>" +
                                            "<img src='http://cdn.xsmore.com/Images/zmkm/sy-124.png' ng-if='" + (!model1.PreSell && model1.IsDisplay && model1.RealStock <= 0) + "' class='cover'>" +
                                            "</span>" +
                                            "<p class='name2'>" + model1.ProductName + "</p>" +
                                            "<p class='price-n'>秒杀价<i>" + model1.Price + "</i>元</p>" +
                                            "<p class='price-e'>售价：<i>&yen;" + model1.MarketPrice + "</i></p>" +
                                            "</div> ";
                                        var model2 = value.MouduleContent.Spikes[2];
                                        if (model2) {
                                            righthtml += " <div class='right-info bottom' ui-sref='shop.product({sku:\"" + model2.ProductSku + "\",shopno:Member.ShopNo})'>" +
                                                "<span class='img'><img src='" + $rootScope.ImgHost + model2.ProductImgUrl + "'>" +
                                                "<img src='http://cdn.xsmore.com/Images/zmkm/sy-122.png'  class='cover' ng-if='" + (model2.PreSell) + "'>" +
                                                "<img src='http://cdn.xsmore.com/Images/zmkm/sy-124.png' ng-if='" + (!model2.PreSell && model2.IsDisplay && model2.RealStock <= 0) + "' class='cover'>" +
                                                "</span>" +
                                                "<p class='name2'>" + model2.ProductName + "</p>" +
                                                "<p class='price-n'>秒杀价<i>" + model2.Price + "</i>元</p>" +
                                                "<p class='price-e'>售价：<i>&yen;" + model2.MarketPrice + "</i></p>" +
                                                "</div> ";
                                        }
                                    }
                                }

                                html = html.concat(" <div class='right'>" +
                                    "<div class='right-det'> " + righthtml + " </div></div> " + lefthtml);
                                html = html.concat("  </div>");
                                break;
                        }

                        html = html.concat("   <a href='' class='link' ui-sref='shop.spike({shopno:Member.ShopNo,pageid:PageId})'><img src='http://cdn.xsmore.com/Images/zmkm/ping.png'>查看更多限时活动&gt;&gt;</a>");

                    }

                    break;
                case 8: //营销活动
                    if (!value.MouduleContent.ActivityInfo || value.MouduleContent.ActivityInfo.length <= 0) {
                        break;
                    }

                    switch (value.MouduleContent.Style) {
                        case 2:
                            var activity = value.MouduleContent.ActivityInfo[0];

                            html = html.concat("<div class=\"active\" ui-sref='" + getactivitysref(activity) + "'>" +
                                "<img src=\"" + $rootScope.ImgHost + activity.ImgUrl + "\">" +
                                "<div class=\"info\">" +
                                "<p class=\"t1\">" + activity.Name + "</p><p class=\"t2\">" + activity.SubTitle + "</p>" +
                                "</div>" +
                                "</div>");
                            break;
                        case 3:
                            var activity0 = value.MouduleContent.ActivityInfo[0];

                            if (activity0) {
                                html = html.concat("  <div class='active active-two clearfix'>");

                                html = html.concat(" <div class=\"left\" ui-sref='" + getactivitysref(activity0) + "'>" +
                                    "<img src=\"" + $rootScope.ImgHost + activity0.ImgUrl + "\">" +
                                    "<div class=\"info\">" +
                                    "<p class=\"t1\">" + activity0.Name + "</p><p class=\"t2\">" + activity0.SubTitle + "</p>" +
                                    "</div>" +
                                    "</div>");
                                var activity1 = value.MouduleContent.ActivityInfo[1];

                                if (activity1) {

                                    html = html.concat(" <div class=\"right\" ui-sref='" + getactivitysref(activity1) + "'>" +
                                        "<img src=\"" + $rootScope.ImgHost + activity1.ImgUrl + "\">" +
                                        "<div class=\"info\">" +
                                        "<p class=\"t1\">" + activity1.Name + "</p><p class=\"t2\">" + activity1.SubTitle + "</p>" +
                                        "</div>" +
                                        "</div>");
                                }
                                html = html.concat("  </div>");
                            }
                            break;
                        case 4:
                            var activity = value.MouduleContent.ActivityInfo[0];

                            html = html.concat("<ul class=\"active-three\" ui-sref='" + getactivitysref(activity) + "'>" +
                                "<li><img src=\"" + $rootScope.ImgHost + activity.ImgUrl + "\">" +
                                "<p class='box'>" +
                                " <span class='txt'>" + activity.Name + "</span> " +
                                "</p>" +
                                "<li></ul>");
                            break;
                        case 5:
                            var activity0 = value.MouduleContent.ActivityInfo[0];

                            if (activity0) {
                                html = html.concat("  <ul class='active-four clearfix'>");

                                html = html.concat(" <li class='boxz' ui-sref='" + getactivitysref(activity0) + "'><div class='ml-box'>" +
                                    "<img src=\"" + $rootScope.ImgHost + activity0.ImgUrl + "\">" +
                                    "<p class='box'>" +
                                    " <span class='txt'>" + activity0.Name + "</span> " +
                                    "</p>" +
                                    "</div></li>");
                                var activity1 = value.MouduleContent.ActivityInfo[1];

                                if (activity1) {

                                    html = html.concat(" <li class='boxz' ui-sref='" + getactivitysref(activity1) + "'><div class='ml-box'>" +
                                        "<img src=\"" + $rootScope.ImgHost + activity1.ImgUrl + "\">" +
                                        "<p class='box'>" +
                                        " <span class='txt'>" + activity1.Name + "</span> " +
                                        "</p>" +
                                        "</div></li>");
                                }
                                html = html.concat("  </ul>");
                            }
                            break;
                        case 0:
                            var activity = value.MouduleContent.ActivityInfo[0];

                            html = html.concat("<div class=\"active-five\" ui-sref='" + getactivitysref(activity) + "'>" +
                                "<img src=\"" + $rootScope.ImgHost + activity.ImgUrl + "\">" +
                                "</div>");
                            break;
                        case 1:
                            var activity0 = value.MouduleContent.ActivityInfo[0];

                            if (activity0) {
                                html = html.concat("  <ul class='active-six clearfix'>");

                                html = html.concat(" <li ui-sref='" + getactivitysref(activity0) + "'><div class='ml-box'>" +
                                    "<img src=\"" + $rootScope.ImgHost + activity0.ImgUrl + "\">" +
                                    "</div></li>");
                                var activity1 = value.MouduleContent.ActivityInfo[1];

                                if (activity1) {

                                    html = html.concat(" <li ui-sref='" + getactivitysref(activity1) + "'><div class='ml-box'>" +
                                        "<img src=\"" + $rootScope.ImgHost + activity1.ImgUrl + "\">" +
                                        "</div></li>");
                                }
                                html = html.concat("  </ul>");
                            }
                            break;
                    }
                    break;
                case 9: //产品专题
                    //console.log(value.MouduleContent);
                    if (value.MouduleContent.WordTopics && value.MouduleContent.WordTopics.length > 0) {
                        html = html.concat($scope.GetTitle(value.MouduleContent, value.MouduleContent.IsShowTitle));
                        switch (value.MouduleContent.Style) {
                            case 0:
                                html = html.concat("<ul class=\"manager-list\">");
                                angular.forEach(value.MouduleContent.WordTopics, function (v9, index) {
                                    html = html.concat("  <li ui-sref='shop.wordtopicdetail({shopno:Member.ShopNo,id:" + v9.Id + "})'>" +
                                        "<img src=\"" + $rootScope.ImgHost + v9.ImgUrl + "\">" +
                                        "<p class=\"box\"><span class=\"txt\" ng-show='" + !value.MouduleContent.IsShowName + "'>" + v9.Name + "</span></p>" +
                                        "</li>");
                                });
                                html = html.concat("</ul>");
                                break;
                            case 1:
                                html = html.concat("<ul class=\"manager-list2 clearfix\">");
                                angular.forEach(value.MouduleContent.WordTopics, function (v9, index) {
                                    html = html.concat("  <li ui-sref='shop.wordtopicdetail({shopno:Member.ShopNo,id:" + v9.Id + "})'>" +
                                        " <div class='ml-box'> " +
                                        "<img src=\"" + $rootScope.ImgHost + v9.ImgUrl + "\">" +
                                        "<p class=\"box\"><span class=\"txt\" ng-show='" + !value.MouduleContent.IsShowName + "'>" + v9.Name + "</span></p></div>" +
                                        "</li>");
                                });
                                html = html.concat("</ul>");
                                break;
                            case 2:
                                //var wordtopic = value.MouduleContent.WordTopics[0];

                                angular.forEach(value.MouduleContent.WordTopics, function (wordtopic, index) {
                                    html = html.concat("<div class='manager-list3-box'><div class='manager-list3'>" +
                                        " <div class='ml-box' ui-sref='shop.wordtopicdetail({shopno:Member.ShopNo,id:" + wordtopic.Id + "})'> " +
                                        "<img src=\"" + $rootScope.ImgHost + wordtopic.ImgUrl + "\">" +
                                        "<p class=\"box\"><span class=\"txt\" ng-show='" + !value.MouduleContent.IsShowName + "'>" + wordtopic.Name + "</span></p></div>");

                                    if (wordtopic.TopicProducts.length > 0) {
                                        html = html.concat(" <div class='xiang ml-box2'><div class='box2'><ul class='infor clearfix'> ");


                                        angular.forEach(wordtopic.TopicProducts, function (v9, index) {

                                            html = html.concat(" <li class='prod'> " +
                                                " <a href='' ui-sref='shop.product({sku:\"" + v9.Sku + "\",shopno:Member.ShopNo})' class='bsx'> " +
                                                " <span class='img'> " +
                                                "<img src=\"" + $rootScope.ImgHost + v9.ImgUrl + "\">" +
                                                "<img src='http://cdn.xsmore.com/Images/zmkm/sy-122.png'  class='cover' ng-if='" + (v9.PreSell) + "'>" +
                                                "<img src='http://cdn.xsmore.com/Images/zmkm/sy-123.png' ng-if='" + (!v9.PreSell && v9.CanSaleStock <= 0) + "' class='cover'>" +
                                                "<img src='http://cdn.xsmore.com/Images/zmkm/sy-121.png'  class='cover' ng-if='" + (!v9.PreSell && v9.CanSaleStock > 0 && !v9.IsDisplay) + "'>" +
                                                " </span><p class='name'>" + v9.ProductName + "</p> " +
                                                " <p class='price'>&yen;" + v9.Price + "</p> " +
                                                " </a></li> ");
                                        });
                                        html = html.concat("</ul></div></div>");
                                    }
                                    html = html.concat("</div></div>");
                                });
                                break;
                            case 3:
                                html = html.concat("<div class=\"manager-list4 xiang\"><div class='box2'><ul class='infor clearfix'>");
                                angular.forEach(value.MouduleContent.WordTopics, function (v9, index) {
                                    html = html.concat("  <li class='prod' >" +
                                        " <a ui-sref='shop.wordtopicdetail({shopno:Member.ShopNo,id:" + v9.Id + "})' class='bsx'> " +
                                        " <span class='img'> " +
                                        "<img src=\"" + $rootScope.ImgHost + v9.ImgUrl + "\">" +
                                        "<p class=\"box\"><span class=\"txt\" ng-show='" + !value.MouduleContent.IsShowName + "'>" + v9.Name + "</span></p></span></a>" +
                                        "</li>");
                                });
                                html = html.concat("</ul></div></div>");
                                break;
                        }
                        html = html.concat("  <a href=\"\" ui-sref='shop.wordtopiclist({shopno:Member.ShopNo})' class=\"link\"><img src=\"http://cdn.xsmore.com/Images/zmkm/damuzhi.png\">查看更多专题&gt;&gt;</a>");
                    }
                    break;
                case 10: //商品模块
                    var moudule = value.MouduleContent.ShopDecorateProduct;
                    html = html.concat($scope.GetTitle(moudule, moudule.IsShowTitle));
                    var mouduleIndex = $scope.ProductReddits.length;
                    $scope.ProductReddits.push(new Reddit('/shop/IndexProductList', { Skip: 0, Take: 6, MemberId: $scope.Member.Id, MouduleIndex: mouduleIndex, PageId: $scope.PageId }));
                    //   console.log(1);

                    switch (moudule.Style) {
                        case 0:
                            html = html.concat("<div class=\"new-shop new-shop3\" infinite-scroll='ProductReddits[" + mouduleIndex + "].nextPage()' infinite-scroll-disabled='ProductReddits[" + mouduleIndex + "].busy' infinite-scroll-distance='3'>");
                            html = html.concat("    <div class='new-pro' ng-repeat='v10 in ProductReddits[" + mouduleIndex + "].items' ui-sref='shop.product({shopno:Member.ShopNo,sku: v10.Sku })'>" +
                                "<span class='img'>" +
                                "<img ng-src='{{ ImgHost + v10.ImgUrl }}'>" +
                                "<img ng-if='v10.PreSell' src=\"http://cdn.xsmore.com/Images/zmkm/will-sale.png\" class=\"cover\">" +
                                "<img ng-if='!v10.PreSell&&v10.Stock<=0' src=\"http://cdn.xsmore.com/Images/zmkm/sold-all.png\" class=\"cover\">" +
                                "<img ng-if='!v10.PreSell&&v10.Stock>0&&!v10.IsDisplay' src=\"http://cdn.xsmore.com/Images/zmkm/sy-121.png\" class=\"cover\">" +
                                "</span><div class='new-infor'><p class='name'>{{v10.Name}}</p>" +
                                " <p class='new-price'>&yen;{{v10.Price}}<i>&yen;{{v10.MarketPrice}}</i></p> " +
                                "<span class='btn theme-bg'>立即购买</span>" +
                                "</div></div>");
                            html = html.concat("</div>");
                            break;
                        case 1:
                            html = html.concat("<div class=\"new-shop shop-flex clearfix\" infinite-scroll='ProductReddits[" + mouduleIndex + "].nextPage()' infinite-scroll-disabled='ProductReddits[" + mouduleIndex + "].busy' infinite-scroll-distance='3'>");
                            html = html.concat("    <div class='shop' ng-repeat='v10 in ProductReddits[" + mouduleIndex + "].items' ui-sref='shop.product({shopno:Member.ShopNo,sku: v10.Sku })'>" +
                                " <div class='shop-det'> " +
                                "<div class='img'>" +
                                "<img ng-src='{{ ImgHost + v10.ImgUrl }}' class='pro-pic'>" +
                                "<img ng-if='v10.PreSell' src=\"http://cdn.xsmore.com/Images/zmkm/will-sale.png\" class=\"cover\">" +
                                "<img ng-if='!v10.PreSell&&v10.Stock<=0' src=\"http://cdn.xsmore.com/Images/zmkm/sold-all.png\" class=\"cover\">" +
                                "<img ng-if='!v10.PreSell&&v10.Stock>0&&!v10.IsDisplay' src=\"http://cdn.xsmore.com/Images/zmkm/sy-121.png\" class=\"cover\">" +
                                "</div><p class='name'>{{v10.Name}}</p>" +
                                "<p class='price'>&yen;<i class='big'>{{v10.Price}}</i><span class='old'>市场价：<i>&yen;{{v10.MarketPrice}}</i></span></p>" +
                                "<span class='lock'><img src='http://cdn.xsmore.com/Images/zmkm/lock.png'></span>" +
                                "</div></div>");
                            html = html.concat("</div>");
                            break;
                        case 2:
                            html = html.concat("<div class=\"new-shop\" infinite-scroll='ProductReddits[" + mouduleIndex + "].nextPage()' infinite-scroll-disabled='ProductReddits[" + mouduleIndex + "].busy' infinite-scroll-distance='3'>");
                            html = html.concat("    <div class='shop clearfix' ng-repeat='v10 in ProductReddits[" + mouduleIndex + "].items' ui-sref='shop.product({shopno:Member.ShopNo,sku: v10.Sku })'>" +
                                "<div class='img'>" +
                                "<img ng-src='{{ ImgHost + v10.ImgUrl }}' class='pro-pic'>" +
                                "<img ng-if='v10.PreSell' src=\"http://cdn.xsmore.com/Images/zmkm/will-sale.png\" class=\"cover\">" +
                                "<img ng-if='!v10.PreSell&&v10.Stock<=0' src=\"http://cdn.xsmore.com/Images/zmkm/sold-all.png\" class=\"cover\">" +
                                "<img ng-if='!v10.PreSell&&v10.Stock>0&&!v10.IsDisplay' src=\"http://cdn.xsmore.com/Images/zmkm/sy-121.png\" class=\"cover\">" +
                                "</div><p class='name'>{{v10.Name}}</p>" +
                                " <p class='price'>&yen;<i>{{v10.Price}}</i></p> " +
                                " <p class='old'>售价: <i>&yen;{{v10.MarketPrice}}元</i></p> " +
                                "<span class='lock'><img src='http://cdn.xsmore.com/Images/zmkm/lock.png'></span>" +
                                "</div>");
                            html = html.concat("</div>");
                            break;
                    }

                    break;
                case 11: //单品推荐
                    var singlemouduleIndex = $scope.SingleProductReddits.length;
                    $scope.SingleProductReddits.push(new Reddit('/shop/SingleProductList', { Skip: 0, Take: 6, MemberId: $scope.Member.Id, Index: singlemouduleIndex, PageId: $scope.PageId }));
                    html = html.concat($scope.GetTitle(value.MouduleContent.ShopDecorateSingleProduct, value.MouduleContent.ShopDecorateSingleProduct.isShowTitle));
                    html = html.concat("<div infinite-scroll='SingleProductReddits[" + singlemouduleIndex + "].nextPage()' infinite-scroll-disabled='SingleProductReddits[" + singlemouduleIndex + "].busy' infinite-scroll-distance='3'>" +
                        "<div class='simple-pro' ng-repeat='item in SingleProductReddits[" + singlemouduleIndex + "].items'><div class='img'>" +
                        "<img ng-src='{{ImgHost+item.ImgUrl}}' ui-sref='shop.product({shopno:Member.ShopNo,sku:item.Sku})' class=\"pro-pic\">" +
                        "<img ng-if='item.PreSell' src=\"http://cdn.xsmore.com/Images/zmkm/will-sale.png\" class=\"sold-all\">" +
                        "<img ng-if='!item.PreSell&&item.Stock<=0' src=\"http://cdn.xsmore.com/Images/zmkm/sold-all.png\" class=\"sold-all\">" +
                        "<img ng-if='!item.PreSell&&item.Stock>0&&!item.IsDisplay' src=\"http://cdn.xsmore.com/Images/zmkm/sy-121.png\" class=\"sold-all\">" +
                        "</div><p class='name'>{{item.Name}}</p>" +
                        "<p class='info'>{{item.Description}}</p>" +
                        "<div class='btn clearfix'>" +
                        "<span class='price theme-border theme-color'>&yen;{{item.Price}} <i>&yen;{{item.MarketPrice}}</i></span>" +
                        "<span  class='mark' ng-click=\"Favorite(item.Sku,'dp'+$index)\"><img id='dp{{$index}}_img' ng-src='{{item.Favorited?\"http://cdn.xsmore.com/Images/zmkm/collected.png\":\"http://cdn.xsmore.com/Images/zmkm/st-1.png\"}}'><i id='dp{{$index}}_num'>{{item.FavoriteCount}}</i></span>" +
                        "</div>" +
                        "</div></div>");

                    //      $scope.SingleModel = value.MouduleContent.SingleProductInfo;
                    //      html = html.concat(" <div class='simple-pro'><div class='img'> " +
                    //          "<img src='" + $rootScope.ImgHost + $scope.SingleModel.ImgUrl + "' ui-sref='shop.product({shopno:Member.ShopNo,sku:\"" + $scope.SingleModel.Sku + "\"})' class='pro-pic'>" +
                    //"<img ng-if='SingleModel.PreSell' src=\"http://cdn.xsmore.com/Images/zmkm/will-sale.png' class='sold-all\">" +
                    //              "<img ng-if='!SingleModel.PreSell && SingleModel.Stock <= 0' src='http://cdn.xsmore.com/Images/zmkm/sold-all.png' class='sold-all'>" +
                    //              "<img ng-if='!SingleModel.PreSell && SingleModel.Stock > 0 && !SingleModel.IsDisplay' src='http://cdn.xsmore.com/Images/zmkm/sy-121.png' class='sold-all'>" +
                    //              "</div><p class='name'>" + $scope.SingleModel.Name + "</p>" +
                    //          "<p class='info'>" + $scope.SingleModel.Description + "</p>" +
                    //          "<div class='btn clearfix'>" +
                    //          "<span class='price theme-border theme-color'>&yen;" + $scope.SingleModel.Price + " <i>&yen;" + $scope.SingleModel.MarketPrice + "</i></span>" +
                    //          "<span  class='mark' ng-click='Favorite(" + $scope.SingleModel.Sku + "," + "dp" + $scope.SingleModel.Id + ")'><img id='dp" + $scope.SingleModel.Id + "_img' ng-src='" + ($scope.SingleModel.Favorited ? 'http://cdn.xsmore.com/Images/zmkm/collected.png' : 'http://cdn.xsmore.com/Images/zmkm/st-1.png') + "'><i id='dp" + $scope.SingleModel.Id + "_num'>" + $scope.SingleModel.FavoriteCount + "</i></span>" +
                    //          " </div></div> ");

                    break;
                case 12:
                    //console.log(value.MouduleContent);
                    //html = html.concat($scope.GetTitle(value.MouduleContent));
                    switch (value.MouduleContent.ShopDecorateBrand.Style) {
                        case 0:
                            html = html.concat("<ul class=\"category clearfix\">");
                            angular.forEach(value.MouduleContent.ShopDecorateBrand.Brands, function (v12, index) {
                                if (v12.Id) {
                                    var uisref = "shop.productlist({shopno:Member.ShopNo,cateId:" + v12.Id + "})";
                                    html = html.concat("<li class=\"cate-list theme-bg\" ui-sref='" + uisref + "'>" + v12.Name + "</li>");
                                }

                            });
                            html = html.concat("</ul>");
                            break;
                        case 1:
                            html = html.concat("<ul class=\"category row3 clearfix\">");
                            angular.forEach(value.MouduleContent.ShopDecorateBrand.Brands, function (v12, index) {
                                if (v12.Id) {
                                    var uisref = "shop.productlist({shopno:Member.ShopNo,cateId:" + v12.Id + "})";
                                    html = html.concat("<li class=\"cate-list boxz\" ui-sref='" + uisref + "'><span class='list theme-bg'>" + v12.Name + "</span></li>");
                                }
                            });
                            html = html.concat("</ul>");
                            break;
                    }
                    break;
                case 13:
                    switch (value.MouduleContent.ShopDecoratePicture.Style) {
                        case 0:
                            html = html.concat("<ul class='pic-navi navi-1'>");
                            angular.forEach(value.MouduleContent.ShopDecoratePicture.Pictures, function (v13, index) {
                                var img = v13.Img ? $rootScope.ImgHost + v13.Img : 'http://cdn.xsmore.com/Images/zmkm/class.png';
                                html = html.concat("	<li><span class=\"img\" " + GetFunction(v13, $scope) + ">" +
                                    "<img  src=\"" + img + "\" >" +
                                    "</span></li>");
                            });
                            html = html.concat("</ul>");
                            break;
                        case 1:
                            html = html.concat("<ul class='pic-navi navi-2 clearfix'>");
                            angular.forEach(value.MouduleContent.ShopDecoratePicture.Pictures, function (v13, index) {
                                var img = v13.Img ? $rootScope.ImgHost + v13.Img : 'http://cdn.xsmore.com/Images/zmkm/class.png';
                                html = html.concat("	<li><span class=\"img\" " + GetFunction(v13, $scope) + ">" +
                                    "<img  src=\"" + img + "\" >" +
                                    "</span></li>");
                            });
                            html = html.concat("</ul>");
                            break;
                        case 2:
                            html = html.concat("<div class='pic-navi navi-5 manager-list4 xiang'><div class='box2'><ul class='infor clearfix'>");
                            angular.forEach(value.MouduleContent.ShopDecoratePicture.Pictures, function (v13, index) {
                                var img = v13.Img ? $rootScope.ImgHost + v13.Img : 'http://cdn.xsmore.com/Images/zmkm/class.png';
                                html = html.concat("	<li class='prod'><a class=\"bsx\" " + GetFunction(v13, $scope) + ">" +
                                    " <span class='img'> " +
                                    "<img  src=\"" + img + "\" >" +
                                    "</span></a></li>");
                            });
                            html = html.concat("</ul></div></div>");
                            break;
                        case 3:
                            html = html.concat("<div class=\"pic-navi navi-3 clearfix\">");
                            var lefthtml = "", righthtml = "";

                            var model0 = value.MouduleContent.ShopDecoratePicture.Pictures[0];
                            if (model0) {
                                var img0 = model0.Img ? $rootScope.ImgHost + model0.Img : 'http://cdn.xsmore.com/Images/zmkm/class.png';
                                lefthtml = " <div class='pic left'>" +
                                    "<span class='img' " + GetFunction(model0, $scope) + "><img src='" + img0 + "'></span></div> ";

                                var model1 = value.MouduleContent.ShopDecoratePicture.Pictures[1];
                                if (model1) {
                                    var img1 = model1.Img ? $rootScope.ImgHost + model1.Img : 'http://cdn.xsmore.com/Images/zmkm/class.png';
                                    righthtml += "<span class='img1' " + GetFunction(model1, $scope) + "><img src='" + img1 + "'></span>";

                                    var model2 = value.MouduleContent.ShopDecoratePicture.Pictures[2];
                                    if (model2) {
                                        var img2 = model2.Img ? $rootScope.ImgHost + model2.Img : 'http://cdn.xsmore.com/Images/zmkm/class.png';
                                        righthtml += "<span class='img1' " + GetFunction(model2, $scope) + "><img src='" + img2 + "'></span>";
                                    }
                                }
                            }

                            html = html.concat(lefthtml + " <div class='pic right'>" +
                                "<div class='pic-det'> " + righthtml + " </div></div> ");
                            html = html.concat("  </div>");
                            break;
                        case 4:
                            html = html.concat("<div class=\"pic-navi navi-3 clearfix\">");
                            var lefthtml = "", righthtml = "";

                            var model0 = value.MouduleContent.ShopDecoratePicture.Pictures[0];
                            if (model0) {
                                var img0 = model0.Img ? $rootScope.ImgHost + model0.Img : 'http://cdn.xsmore.com/Images/zmkm/class.png';
                                lefthtml = " <div class='pic left'>" +
                                    "<span class='img' " + GetFunction(model0, $scope) + "><img src='" + img0 + "'></span></div> ";

                                var model1 = value.MouduleContent.ShopDecoratePicture.Pictures[1];
                                if (model1) {
                                    var img1 = model1.Img ? $rootScope.ImgHost + model1.Img : 'http://cdn.xsmore.com/Images/zmkm/class.png';
                                    righthtml += "<span class='img1' " + GetFunction(model1, $scope) + "><img src='" + img1 + "'></span>";

                                    var model2 = value.MouduleContent.ShopDecoratePicture.Pictures[2];
                                    if (model2) {
                                        var img2 = model2.Img ? $rootScope.ImgHost + model2.Img : 'http://cdn.xsmore.com/Images/zmkm/class.png';
                                        righthtml += "<span class='img1' " + GetFunction(model2, $scope) + "><img src='" + img2 + "'></span>";
                                    }
                                }
                            }

                            html = html.concat(" <div class='pic right'>" +
                                "<div class='pic-det'> " + righthtml + " </div></div> " + lefthtml);
                            html = html.concat("  </div>");
                            break;
                    }
                    break;
                case 14:
                    switch (value.MouduleContent.ShopDecorateCoupon.Style) {
                        case 0:
                            angular.forEach(value.MouduleContent.ShopDecorateCoupon.ActivityInfo, function (v14, index) {
                                html = html.concat(" <div class='yhq' ui-sref='shop.activitycoupon({id:" + v14.ActivityId + ",mid:Member.Id})'>" +
                                    " <img src='" + $rootScope.ImgHost + v14.ImgUrl + "' style='display: block;width: 100%;'></div> ");
                            });
                            break;
                    }
                    break;
                case 15:
                    html = html.concat(" <div class='isolation' style='height: " + value.MouduleContent.ShopDecorateMargin + "px;'></div>");
                    break;
                case 16:
                    switch (value.MouduleContent.Style) {
                        case 0:
                            html = html.concat("<div class='sy-style-nav white-bg'>");
                            angular.forEach(value.MouduleContent.ShopDecorateFooter, function (v16, index) {
                                var tempspan = "";
                                if (v16.imgId == -1) {
                                    tempspan = "	<div><a " + GetFunction(v16, $scope) + ">" +
                                        " <img src='" + v16.ImgUrl + "' style='display:block; width:2rem;height:2rem;margin: 0 auto 0.3rem;' /> " +
                                        "<i>" + v16.Name + "</i>" +
                                        "</a></div>";
                                } else {
                                    tempspan = "	<div><a " + GetFunction(v16, $scope) + ">" +
                                    " <span class='footer-tab-" + v16.imgId + "'></span> " +
                                    "<i>" + v16.Name + "</i>" +
                                    "</a></div>";
                                }
                                html = html.concat(tempspan);
                            });
                            html = html.concat("</div>");
                            break;
                        case 1:
                            html = html.concat("<div class='sy-style-nav black-bg '>");
                            angular.forEach(value.MouduleContent.ShopDecorateFooter, function (v16, index) {
                                var tempspan = "";
                                if (v16.imgId == -1) {
                                    tempspan = "	<div><a " + GetFunction(v16, $scope) + ">" +
                                        " <img src='" + v16.ImgUrl + "' style='display:block; width:2rem;height:2rem;margin: 0 auto 0.3rem;' /> " +
                                        "<i>" + v16.Name + "</i>" +
                                        "</a></div>";
                                } else {
                                    tempspan = "	<div><a " + GetFunction(v16, $scope) + ">" +
                                    " <span class='footer-tab-" + v16.imgId + "'></span> " +
                                    "<i>" + v16.Name + "</i>" +
                                    "</a></div>";
                                }
                                html = html.concat(tempspan);
                            });
                            html = html.concat("</div>");
                            break;
                    }
                    break;
                case 17:
                    if (value.MouduleContent.ShopDecorateGroup && value.MouduleContent.ShopDecorateGroup.Products.length > 0 && value.MouduleContent.ShopDecorateGroup.Products[0].Productdata) {
                        var moudule = value.MouduleContent.ShopDecorateGroup;
                        html = html.concat($scope.GetTitle(moudule, moudule.IsShowTitle));
                        html = html.concat(" <div class='pintuan'> ");
                        angular.forEach(moudule.Products, function (v17, index) {
                            if (v17.Productdata) {
                                html = html.concat(" <div class='pro_box'><div class='pt_box'> " +
                                    " <img src='" + $rootScope.ImgHost + v17.img + "' class='pimg'> " +
                                    " <div class='pbg posa'></div> " +
                                    " <p class=' ppc posa' data-time='" + v17.Productdata.End + "'> " +
                                    (v17.Productdata.ActivityState == "进行中" ? " <i class='ii'></i>剩余<span class='time0'>1</span><em>天</em><span class='time1'>20</span><em>小时</em><span class='time2'>19</span><em>分</em><span class='time3'>11</span><em>秒</em></p></div> " : "<i class='ii'></i>" + v17.Productdata.ActivityBeginTime + "开始</p></div>") +
                                    " <p class='name'>" + v17.Productdata.Name + "</p> " +
                                    " <p class='info'>" + v17.Productdata.ProductDesc + "</p> " +
                                    " <p class='cases'>原价：<span>¥&nbsp;" + v17.Productdata.MaxProductPrice + "</span> " +
                                    " <span class='fr'>已有<span class='red theme-color'>" + v17.Productdata.Joined + "</span>人参团</span> " +
                                    " </p><div class='boxc'> " +
                                    " <div class='bgc posa'></div><div class='ii posa codrops theme-bg'><span class='img'><img src='http://cdn.xsmore.com/Images/zmkm/sy-130.png'></span></div> " +
                                    " <span class='wz posa'>" + v17.Productdata.GroupCount + "人开团</span> " +
                                    " <span class='prc posa'>¥<span>" + v17.Productdata.MinGroupBuyingPrice + "</span></span> " +
                                    " <a href='javascript:void(0)'  class='aback posa theme-bg' ui-sref='shop.groupbuydetail({id:" + v17.Productdata.Id + ",shopno:Member.ShopNo})'>" + (v17.Productdata.ActivityState == "进行中" ? "去开团" : "即将开始") + "</a></div></div> ");
                            }
                        });
                        html = html.concat(" </div><a href='javascript:void(0)' ui-sref='shop.groupbuylist({shopno:Member.ShopNo})' class='link'><img src='http://cdn.xsmore.com/Images/zmkm/sy-131.png'>查看更多团购活动&gt;&gt;</a> ");
                    }
                    break;
                case 18:
                    var moudule = value.MouduleContent.ShopDecorateVideo;
                    angular.forEach(moudule.Products, function (v18, index) {
                        html = html.concat("<div class='video-wraper' ui-sref='shop.video({id:" + v18.Video.Id + ",shopno:Member.ShopNo})'>" +
                            "<div class='video-box' style=''>" +
                            //"	<video width='100%' height='100%' preload='auto' webkit-playsinline='' controls='controls' load='loaded' id='product-video' style='display: inline-block;'>" +
                            //"       <source src='" + $rootScope.ImgHost + v18.Video.Url + "' type='video/mp4'>" +
                            //"      </video>" +
                            "<img null-src='http://cdn.xsmore.com/Images/zmkm/class.png'  src='" + $rootScope.ImgHost + v18.Video.ImgUrl + "' class='cover'>" +
                            //(v18.Video.ImgUrl ? ("<img src='" + $rootScope.ImgHost + v18.Video.ImgUrl + "' class='cover' style=''>") : "") +
                            "    <span class='play' style=''>" +
                            //(v18.Video.ImgUrl ?  "<img src='http://cdn.xsmore.com/Images/zmkm/fit/go.png' style='display: block;width: 100%;'>)" : "")+
                            //"<img src='http://cdn.xsmore.com/Images/zmkm/fit/go.png' style='display: block;width: 100%;'>)"+
                            "</span>" +
                            "	</div>" +
                            "	<p style='padding:1rem;background:#fff;font-size:1.2rem;'>" + (v18.Video.Describe ? v18.Video.Describe : "") + "</p>" +
                            "	<div class='play-number clearfix'>" +
                            "	<img src='http://cdn.xsmore.com/Images/zmkm/1-61@2x.png'>" + v18.Video.MS[0] + "’" + v18.Video.MS[1] + "”" +
                            "	<img src='http://cdn.xsmore.com/Images/zmkm/2-62@2x.png'>" + v18.Video.PlayTimes +
                            "	</div>" +
                            "	</div>");
                    });
                    break;
                case 19:
                    if (value.MouduleContent.ShopDecorateRob && value.MouduleContent.ShopDecorateRob.Products.length > 0) {
                        var moudule = value.MouduleContent.ShopDecorateRob;
                        html = html.concat($scope.GetTitle(moudule, moudule.IsShowTitle));
                        switch (moudule.Style) {
                            case 0:
                                html = html.concat(" <ul class='duobao clearfix'> ");
                                angular.forEach(moudule.Products, function (v19, index) {
                                    switch (v19.Productdata.TreasureActivityState) {
                                        case "未开始":
                                            html = html.concat(" <li class='db-list boxz' ui-sref='shop.treasureDetailPage({Id:" + v19.Productdata.Activity_TreasureId + ",shopno:Member.ShopNo})' > " +
                                                " <span class='img'> <img src='" + $rootScope.ImgHost + v19.img + "' class='pro-img'></span>" +
                                                " <p class='db-pro-name'>" + v19.Productdata.ProductName + "</p> " +
                                                " <div class='db-pro-det jindu clearfix'> " +
                                                " <div class='left'> " +
                                                " <p class='top'>揭晓进度<i>" + (v19.Productdata.SaleCount / v19.Productdata.TotalCount * 100).toFixed(2) + "%</i></p> " +
                                                " <p class='bg'><span class='color'></span></p> " +
                                                " </div><div class='right'> " +
                                                " <a href='javascript:void(0);' class='db-go theme-color theme-border boxz'>即将开始</a> " +
                                                " </div></div></li> ");
                                            break;
                                        case "进行中":
                                            html = html.concat(" <li class='db-list boxz' ui-sref='shop.treasureDetailPage({Id:" + v19.Productdata.Activity_TreasureId + ",shopno:Member.ShopNo})' > " +
                                                " <span class='img'> <img src='" + $rootScope.ImgHost + v19.img + "' class='pro-img'></span>" +
                                                " <p class='db-pro-name'>" + v19.Productdata.ProductName + "</p> " +
                                                " <div class='db-pro-det jindu clearfix'> " +
                                                " <div class='left'> " +
                                                " <p class='top'>揭晓进度<i>" + (v19.Productdata.SaleCount / v19.Productdata.TotalCount * 100).toFixed(2) + "%</i></p> " +
                                                " <p class='bg'><span class='color'></span></p> " +
                                                " </div><div class='right'> " +
                                                " <a href='javascript:void(0);' class='db-go theme-color theme-border boxz'>立即夺宝</a> " +
                                                " </div></div></li> ");
                                            break;
                                        case "揭晓中":
                                            html = html.concat(" <li class='db-list boxz' ui-sref='shop.treasureDetailPage({Id:" + v19.Productdata.Activity_TreasureId + ",shopno:Member.ShopNo})' > " +
                                                " <span class='img'> <img src='" + $rootScope.ImgHost + v19.img + "' class='pro-img'></span>" +
                                                " <p class='db-pro-name'>" + v19.Productdata.ProductName + "</p> " +
                                                " <p class='db-pro-det will-down theme-color'>即将揭晓  正在计算，请稍等片刻...</p> " +
                                                " </li> ");
                                            break;
                                            //case "已结束":
                                            //    html = html.concat(" <li class='db-list boxz' ui-sref='shop.treasureDetailPage({Id:" + v19.Productdata.Activity_TreasureId + ",shopno:Member.ShopNo})' > " +
                                            //        " <span class='img'> <img src='" + $rootScope.ImgHost + v19.img + "' class='pro-img'>" +
                                            //        " <img src='http://cdn.xsmore.com/Images/zmkm/sy-129.png' class='jiexiao'></span> " +
                                            //        " <p class='db-pro-name'>" + v19.Productdata.ProductName + "</p> " +
                                            //        " <div class='db-pro-det lucky-num clearfix'> " +
                                            //        " <div class='left'> " +
                                            //        " 幸运号码：<i>" + v19.Productdata.LuckyNo + "</i> " +
                                            //        " </div><div class='right'> " +
                                            //        " <i>" + v19.Productdata.SaleCount + "</i>人次 " +
                                            //        " </div></div></li> ");
                                            //    break;
                                    }
                                });
                                break;
                            case 1:
                                html = html.concat(" <ul class='duobao2'> ");
                                angular.forEach(moudule.Products, function (v19, index) {
                                    switch (v19.Productdata.TreasureActivityState) {
                                        case "未开始":
                                            html = html.concat(" <li class='clearfix boxz'> " +
                                                " <span class='img'><img src='" + $rootScope.ImgHost + v19.img + "'></span> " +
                                                " <div class='middle jindu'><p class='db-pro-name'>" + v19.Productdata.ProductName + "</p> " +
                                                " <div class='jindu-det'> " +
                                                " <p class='bg'><span class='color'></span></p> " +
                                                " <p class='lr clearfix'> " +
                                                " <span class='left'>总需<i>" + v19.Productdata.TotalCount + "</i></span> " +
                                                " <span class='right'>剩余<i>" + v19.Productdata.RemainCount + "</i></span> " +
                                                " </p></div> " +
                                                " </div><span class='btn theme-color theme-border' ui-sref='shop.treasureDetailPage({Id:" + v19.Productdata.Activity_TreasureId + ",shopno:Member.ShopNo})' >即将开始</span> " +
                                                " </li> ");
                                            break;
                                        case "进行中":
                                            html = html.concat(" <li class='clearfix boxz'> " +
                                                " <span class='img'><img src='" + $rootScope.ImgHost + v19.img + "'></span> " +
                                                " <div class='middle jindu'><p class='db-pro-name'>" + v19.Productdata.ProductName + "</p> " +
                                                " <div class='jindu-det'> " +
                                                " <p class='bg'><span class='color'></span></p> " +
                                                " <p class='lr clearfix'> " +
                                                " <span class='left'>总需<i>" + v19.Productdata.TotalCount + "</i></span> " +
                                                " <span class='right'>剩余<i>" + v19.Productdata.RemainCount + "</i></span> " +
                                                " </p></div> " +
                                                " </div><span class='btn theme-color theme-border' ui-sref='shop.treasureDetailPage({Id:" + v19.Productdata.Activity_TreasureId + ",shopno:Member.ShopNo})' >立即夺宝</span> " +
                                                " </li> ");
                                            break;
                                        case "揭晓中":
                                            html = html.concat(" <li class='clearfix boxz'> " +
                                                " <span class='img'><img src='" + $rootScope.ImgHost + v19.img + "'></span> " +
                                                " <div class='middle'><p class='db-pro-name'>" + v19.Productdata.ProductName + "</p> " +
                                                " <p class='db-pro-det will-down theme-color'>即将揭晓  正在计算，请稍等片刻...</p> " +
                                                " </div><span class='btn theme-color theme-border' ui-sref='shop.treasureDetailPage({Id:" + v19.Productdata.Activity_TreasureId + ",shopno:Member.ShopNo})' >查看详情</span> " +
                                                " </li> ");
                                            break;
                                            //case "已结束":
                                            //    html = html.concat(" <li class='clearfix boxz'> " +
                                            //        " <span class='img'><img src='" + $rootScope.ImgHost + v19.img + "'></span> " +
                                            //        " <div class='middle result'><p class='db-pro-name'>" + v19.Productdata.ProductName + "</p> " +
                                            //        " <div class='lucky-num clearfix'> " +
                                            //        " <div class='left'>幸运号码：<i>" + v19.Productdata.LuckyNo + "</i></div> " +
                                            //        " <div class='right'><i>" + v19.Productdata.SaleCount + "</i>人次</div></div> " +
                                            //        " <img src='http://cdn.xsmore.com/Images/zmkm/sy-129.png' class='biaoji'> " +
                                            //        " </div><span class='btn theme-color theme-border' ui-sref='shop.treasureDetailPage({Id:" + v19.Productdata.Activity_TreasureId + ",shopno:Member.ShopNo})' >查看详情</span> " +
                                            //        " </li> ");
                                            //    break;
                                    }
                                });
                                break;
                        }

                        html = html.concat(" </ul><a href='javascript:void(0)' ui-sref='shop.treasureProductList({shopno:Member.ShopNo})' class='link'><img src='http://cdn.xsmore.com/Images/zmkm/ping.png'>查看更多夺宝活动&gt;&gt;</a> ");
                    }
                    break;
                case 20:
                    //GetFunction(v4)
                    if (!value.MouduleContent.Img.url) {
                        break;
                    }
                    html = html.concat(" <div class='hot-area' style='position:relative;width:100%'> " +
                        " <img src='" + value.MouduleContent.Img.url + "' style='display:block;width:100%'> ");
                    angular.forEach(value.MouduleContent.ShopDecorateHot, function (v20, index) {
                        html = html.concat(" <a " + GetFunction(v20, $scope) + " style='position:absolute;left:" + v20.Style.left * 100 + "%;top:" + v20.Style.top * 100 + "%;height:" + v20.Style.height * 100 + "%;width:" + v20.Style.width * 100 + "%;'></a> ");
                    });
                    html = html.concat(" </div> ");
                    break;
                default:
                    break;
            }
        });
        return html;
    };
    return {
        GetFunction: GetFunction,
        GetGameUrl: GetGameUrl,
        GetNotifyUrl: GetNotifyUrl,
        getactivitysref: getactivitysref,
        GetHtml: GetHtml
    };
}]);


App.directive('aDisabled', function () {
    return {
        compile: function (tElement, tAttrs, transclude) {
            //Disable ngClick
            tAttrs["ngClick"] = "!(" + tAttrs["aDisabled"] + ") && (" + tAttrs["ngClick"] + ")";

            //Toggle "disabled" to class when aDisabled becomes true
            return function (scope, iElement, iAttrs) {
                scope.$watch(iAttrs["aDisabled"], function (newValue) {
                    if (newValue !== undefined) {
                        iElement.toggleClass("disabled", newValue);
                    }
                });

                //Disable href on click
                iElement.on("click", function (e) {
                    if (scope.$eval(iAttrs["aDisabled"])) {
                        e.preventDefault();
                    }
                });
            };
        }
    };
})
App.directive(
			"bnLazySrc",
			function ($window, $document) {


			    // I manage all the images that are currently being
			    // monitored on the page for lazy loading.
			    var lazyLoader = (function () {

			        // I maintain a list of images that lazy-loading
			        // and have yet to be rendered.
			        var images = [];

			        // I define the render timer for the lazy loading
			        // images to that the DOM-querying (for offsets)
			        // is chunked in groups.
			        var renderTimer = null;
			        var renderDelay = 100;

			        // I cache the window element as a jQuery reference.
			        var win = $($window);

			        // I cache the document document height so that 
			        // we can respond to changes in the height due to
			        // dynamic content.
			        var doc = $document;
			        var documentHeight = doc.height();
			        var documentTimer = null;
			        var documentDelay = 2000;

			        // I determine if the window dimension events 
			        // (ie. resize, scroll) are currenlty being 
			        // monitored for changes.
			        var isWatchingWindow = false;


			        // ---
			        // PUBLIC METHODS.
			        // ---


			        // I start monitoring the given image for visibility
			        // and then render it when necessary.
			        function addImage(image) {

			            images.push(image);

			            if (!renderTimer) {

			                startRenderTimer();

			            }

			            if (!isWatchingWindow) {

			                startWatchingWindow();

			            }

			        }


			        // I remove the given image from the render queue.
			        function removeImage(image) {

			            // Remove the given image from the render queue.
			            for (var i = 0 ; i < images.length ; i++) {

			                if (images[i] === image) {

			                    images.splice(i, 1);
			                    break;

			                }

			            }

			            // If removing the given image has cleared the
			            // render queue, then we can stop monitoring 
			            // the window and the image queue.
			            if (!images.length) {

			                clearRenderTimer();

			                stopWatchingWindow();

			            }

			        }


			        // ---
			        // PRIVATE METHODS.
			        // ---


			        // I check the document height to see if it's changed.
			        function checkDocumentHeight() {

			            // If the render time is currently active, then 
			            // don't bother getting the document height - 
			            // it won't actually do anything.
			            if (renderTimer) {

			                return;

			            }

			            var currentDocumentHeight = doc.height();

			            // If the height has not changed, then ignore - 
			            // no more images could have come into view.
			            if (currentDocumentHeight === documentHeight) {

			                return;

			            }

			            // Cache the new document height.
			            documentHeight = currentDocumentHeight;

			            startRenderTimer();

			        }


			        // I check the lazy-load images that have yet to 
			        // be rendered. 
			        function checkImages() {

			            // Log here so we can see how often this 
			            // gets called during page activity.
			            //       console.log("Checking for visible images...");

			            var visible = [];
			            var hidden = [];

			            // Determine the window dimensions.
			            var windowHeight = win.height();
			            var scrollTop = win.scrollTop();

			            // Calculate the viewport offsets.
			            var topFoldOffset = scrollTop;
			            var bottomFoldOffset = (topFoldOffset + windowHeight);

			            // Query the DOM for layout and seperate the
			            // images into two different categories: those
			            // that are now in the viewport and those that
			            // still remain hidden.
			            for (var i = 0 ; i < images.length ; i++) {

			                var image = images[i];

			                if (image.isVisible(topFoldOffset, bottomFoldOffset)) {

			                    visible.push(image);

			                } else {

			                    hidden.push(image);

			                }

			            }

			            // Update the DOM with new image source values.
			            for (var i = 0 ; i < visible.length ; i++) {

			                visible[i].render();

			            }

			            // Keep the still-hidden images as the new 
			            // image queue to be monitored.
			            images = hidden;

			            // Clear the render timer so that it can be set
			            // again in response to window changes.
			            clearRenderTimer();

			            // If we've rendered all the images, then stop
			            // monitoring the window for changes.
			            if (!images.length) {

			                stopWatchingWindow();

			            }

			        }


			        // I clear the render timer so that we can easily 
			        // check to see if the timer is running.
			        function clearRenderTimer() {

			            clearTimeout(renderTimer);

			            renderTimer = null;

			        }


			        // I start the render time, allowing more images to
			        // be added to the images queue before the render 
			        // action is executed.
			        function startRenderTimer() {

			            renderTimer = setTimeout(checkImages, renderDelay);

			        }


			        // I start watching the window for changes in dimension.
			        function startWatchingWindow() {

			            isWatchingWindow = true;

			            // Listen for window changes.
			            win.on("resize.bnLazySrc", windowChanged);
			            win.on("scroll.bnLazySrc", windowChanged);

			            // Set up a timer to watch for document-height changes.
			            documentTimer = setInterval(checkDocumentHeight, documentDelay);

			        }


			        // I stop watching the window for changes in dimension.
			        function stopWatchingWindow() {

			            isWatchingWindow = false;

			            // Stop watching for window changes.
			            win.off("resize.bnLazySrc");
			            win.off("scroll.bnLazySrc");

			            // Stop watching for document changes.
			            clearInterval(documentTimer);

			        }


			        // I start the render time if the window changes.
			        function windowChanged() {

			            if (!renderTimer) {

			                startRenderTimer();

			            }

			        }


			        // Return the public API.
			        return ({
			            addImage: addImage,
			            removeImage: removeImage
			        });

			    })();


			    // ------------------------------------------ //
			    // ------------------------------------------ //


			    // I represent a single lazy-load image.
			    function LazyImage(element) {

			        // I am the interpolated LAZY SRC attribute of 
			        // the image as reported by AngularJS.					
			        var source = null;

			        // I determine if the image has already been 
			        // rendered (ie, that it has been exposed to the
			        // viewport and the source had been loaded).
			        var isRendered = false;

			        // I am the cached height of the element. We are 
			        // going to assume that the image doesn't change 
			        // height over time.
			        var height = null;


			        // ---
			        // PUBLIC METHODS.
			        // ---


			        // I determine if the element is above the given 
			        // fold of the page.
			        function isVisible(topFoldOffset, bottomFoldOffset) {

			            // If the element is not visible because it 
			            // is hidden, don't bother testing it.
			            if (!element.is(":visible")) {

			                return (false);

			            }

			            // If the height has not yet been calculated, 
			            // the cache it for the duration of the page.
			            if (height === null) {

			                height = element.height();

			            }

			            // Update the dimensions of the element.
			            var top = element.offset().top;
			            var bottom = (top + height);

			            // Return true if the element is:
			            // 1. The top offset is in view.
			            // 2. The bottom offset is in view.
			            // 3. The element is overlapping the viewport.
			            return (
								(
									(top <= bottomFoldOffset) &&
									(top >= topFoldOffset)
								)
							||
								(
									(bottom <= bottomFoldOffset) &&
									(bottom >= topFoldOffset)
								)
							||
								(
									(top <= topFoldOffset) &&
									(bottom >= bottomFoldOffset)
								)
						);

			        }


			        // I move the cached source into the live source.
			        function render() {

			            isRendered = true;

			            renderSource();

			        }


			        // I set the interpolated source value reported
			        // by the directive / AngularJS.
			        function setSource(newSource) {

			            source = newSource;

			            if (isRendered) {

			                renderSource();

			            }

			        }


			        // ---
			        // PRIVATE METHODS.
			        // ---


			        // I load the lazy source value into the actual 
			        // source value of the image element.
			        function renderSource() {

			            element[0].src = source;

			        }


			        // Return the public API.
			        return ({
			            isVisible: isVisible,
			            render: render,
			            setSource: setSource
			        });

			    }


			    // ------------------------------------------ //
			    // ------------------------------------------ //


			    // I bind the UI events to the scope.
			    function link($scope, element, attributes) {

			        var lazyImage = new LazyImage(element);

			        // Start watching the image for changes in its
			        // visibility.
			        lazyLoader.addImage(lazyImage);


			        // Since the lazy-src will likely need some sort
			        // of string interpolation, we don't want to 
			        attributes.$observe(
						"bnLazySrc",
						function (newSource) {

						    lazyImage.setSource(newSource);

						}
					);


			        // When the scope is destroyed, we need to remove
			        // the image from the render queue.
			        $scope.$on(
						"$destroy",
						function () {

						    lazyLoader.removeImage(lazyImage);

						}
					);

			    }


			    // Return the directive configuration.
			    return ({
			        link: link,
			        restrict: "A"
			    });

			}
		);

App.directive('numbersOnly', function () {
    return {
        require: 'ngModel',
        link: function (scope, element, attr, ngModelCtrl) {
            function fromUser(text) {
                if (text) {
                    var transformedInput = text.toString().replace(/[^0-9]/g, '');

                    if (transformedInput !== text) {
                        ngModelCtrl.$setViewValue(transformedInput);
                        ngModelCtrl.$render();
                    }
                    return transformedInput;
                }
                return undefined;
            }
            ngModelCtrl.$parsers.push(fromUser);
        }
    };
});
/**=========================================================
 * Module: anchor.js
 * Disables null anchor behavior
 =========================================================*/

App.directive('href', function () {

    return {
        restrict: 'A',
        compile: function (element, attr) {
            return function (scope, element) {
                if (attr.ngClick || attr.href === '' || attr.href === '#') {
                    if (!element.hasClass('dropdown-toggle'))
                        element.on('click', function (e) {
                            e.preventDefault();
                            e.stopPropagation();
                        });
                }
            };
        }
    };
});
App.directive('convertToNumber', function () {
    return {
        require: 'ngModel',
        link: function (scope, element, attrs, ngModel) {
            ngModel.$parsers.push(function (val) {
                return parseInt(val, 10);
            });
            ngModel.$formatters.push(function (val) {
                return '' + val;
            });
        }
    };
});
/**=========================================================
 * Module: animate-enabled.js
 * Enable or disables ngAnimate for element with directive
 =========================================================*/

//App.directive("animateEnabled", ["$animate", function ($animate) {
//    return {
//        link: function (scope, element, attrs) {
//            scope.$watch(function () {
//                return scope.$eval(attrs.animateEnabled, scope);
//            }, function (newValue) {
//                $animate.enabled(!!newValue, element);
//            });
//        }
//    };
//}]);
App.directive('goClick', function ($location) {
    return function (scope, element, attrs) {
        var path;

        attrs.$observe('goClick', function (val) {

            path = val;
        });

        element.bind('click', function () {
            scope.$apply(function () {
                $location.path(path);
            });
        });
    };
});


App.service('grabcoupon', ['$http', function ($http) {
    return {
        CouponType: function (coupon) {
            switch (coupon.CouponType) {
                case 1:
                    return "通用券";
                case 2:
                    return "商品券";
                case 3:

                case 4:
                    return "品类券";

                default:
                    return "";
            }
        },
        GetStyle: function (coupon) {
            switch (coupon.Style) {
                case 0:
                case 1:
                    return coupon.Color + " list" + coupon.Style + "-" + coupon.Color + " clearfix";
                case 2:
                    return "color " + coupon.Color + " clearfix";
                case 3:
                    return "list-det";

                default:
                    return "";
            }
        },
        Grab: function (coupon) {
            return $http.post('/homePageCouponActivity/grabnew', { Id: coupon.Id, ActivityId: $stateParams.id, MemberId: $stateParams.mid }).success(function (response) {
                coupon.Grab = true;

            }).error(function (response) {
                alert(response.Message);
            });

        }
    };
}]);

App.provider('RouteHelpers', ['APP_REQUIRES', function (appRequires) {
    "use strict";

    // Set here the base of the relative path
    // for all app views
    this.basepath = function (uri) {
        return '/views/' + uri;
    };

    // Generates a resolve object by passing script names
    // previously configured in constant.APP_REQUIRES
    this.resolveFor = function () {
        var _args = arguments;
        return {
            deps: ['$ocLazyLoad', '$q', function ($ocLL, $q) {
                // Creates a promise chain for each argument
                var promise = $q.when(1); // empty promise
                for (var i = 0, len = _args.length; i < len; i++) {
                    promise = andThen(_args[i]);
                }
                return promise;

                // creates promise to chain dynamically
                function andThen(_arg) {
                    // also support a function that returns a promise
                    if (typeof _arg == 'function')
                        return promise.then(_arg);
                    else
                        return promise.then(function () {
                            // if is a module, pass the name. If not, pass the array
                            var whatToLoad = getRequired(_arg);
                            // simple error check
                            if (!whatToLoad) return $.error('Route resolve: Bad resource name [' + _arg + ']');
                            // finally, return a promise
                            return $ocLL.load(whatToLoad);
                        });
                }
                // check and returns required data
                // analyze module items with the form [name: '', files: []]
                // and also simple array of script files (for not angular js)
                function getRequired(name) {
                    if (appRequires.modules)
                        for (var m in appRequires.modules)
                            if (appRequires.modules[m].name && appRequires.modules[m].name === name)
                                return appRequires.modules[m];
                    return appRequires.scripts && appRequires.scripts[name];
                }

            }]
        };
    }; // resolveFor

    // not necessary, only used in config block for routes
    this.$get = function () {
        return {
            basepath: this.basepath
        }
    };

}]);


App.service('shophot', ["$http", function ($http) {
    var service = {
        Hot: 0,
        AddHot: function (memberid, sku, name) {
            $http.post("/shop/addhot", { MemberId: memberid, Sku: sku, ProductName: name });
        }
    }
    return service;
}]);